omniauth-entra-id 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/UPGRADING.md +60 -5
- data/lib/omniauth/entra_id/version.rb +2 -2
- data/lib/omniauth/strategies/entra_id.rb +11 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8558b73bf91e883370f1545996ad524af244f85a42f2226d959f7ec5ff1aad7c
|
4
|
+
data.tar.gz: 20d399da5278f50bd30e286011d27f5b9bf0927137d45897ac5d3222dcdb9973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec624842a87a29eda78e9015fb3b82313ec17f8538b6d62ea8f9adf7b86d89df3f349d2880729a20c703c26a91b84a2feb69abf177080495117a00b3801f80b
|
7
|
+
data.tar.gz: 8e2528b185ad7577504a592cb09663e1891035c10ea65e856019374eafa03aa81c8e932bc1aedbbbdfbf1db17ede59c36cac76cb8f5088c0b47573cdeac13a1f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v3.0.1 (2024-11-21)
|
4
|
+
|
5
|
+
* Fixes a minor error in [`UPGRADING.md`](UPGRADING.md) reported in #38, via #40 (thanks to @kennethgeerts)
|
6
|
+
* Fixes incorrect attempt to verify JWT token issuer when the AD FS tenant `adfs` is specified, via #39 (thanks to @washu)
|
7
|
+
|
3
8
|
## v3.0.0 (2024-10-22)
|
4
9
|
|
5
10
|
* To upgrade from the Azure ActiveDirectory V2 gem, please see [`UPGRADING.md`](UPGRADING.md)
|
data/README.md
CHANGED
@@ -116,7 +116,7 @@ If you're using the client assertion flow, you need to register your certificate
|
|
116
116
|
| `authorize_params` | Additional parameters passed as URL query data in the initial OAuth redirection to Microsoft. See below for more. Empty Hash default. |
|
117
117
|
| `domain_hint` | If defined, sets (overwriting, if already present) `domain_hint` inside `authorize_params`. Default `nil` / none. |
|
118
118
|
| `scope` | If defined, sets (overwriting, if already present) `scope` inside `authorize_params`. Default is `OmniAuth::Strategies::EntraId::DEFAULT_SCOPE` (at the time of writing, this is `'openid profile email'`). |
|
119
|
-
| `adfs`
|
119
|
+
| `adfs?` or `adfs` | If set to `true`, modifies the URLs so they work with an on-premise AD FS server (Active Directory Federation Services). In order to use this you also need to set the `base_url` correctly and fill the `tenant_id` with `'adfs'`. Note that the option name variation without the question mark only works for directly-specified options; provider classes must always define an override method called `adfs?`. |
|
120
120
|
|
121
121
|
In addition, as a special case, if the request URL contains a query parameter `prompt`, then this will be written into `authorize_params` under that key, overwriting if present any other value there. Note that this comes from the current request URL at the time OAuth flow is commencing, _not_ via static options Hash data or via a custom provider class - but you _could_ just as easily set `scope` inside a custom `authorize_params` returned from a provider class, as shown in an example later; the request URL query mechanism is just another way of doing the same thing.
|
122
122
|
|
data/UPGRADING.md
CHANGED
@@ -45,7 +45,7 @@ https://example.com/v1/auth/azure_activedirectory_v2/callback
|
|
45
45
|
...is now:
|
46
46
|
|
47
47
|
```
|
48
|
-
https://example.com/v1/auth/
|
48
|
+
https://example.com/v1/auth/entra_id/callback
|
49
49
|
```
|
50
50
|
|
51
51
|
### URL generation
|
@@ -65,8 +65,8 @@ omniauth_authorize_url('resource_name_eg_user', 'entra_id', scope: '...')
|
|
65
65
|
|
66
66
|
|
67
67
|
## Updates due to other breaking changes
|
68
|
-
|
69
|
-
|
68
|
+
### Change affecting all gem users
|
69
|
+
#### UIDs will change
|
70
70
|
|
71
71
|
This change is for UIDs and is the main reason for creating a V3 gem, whether or not it included the Entra name change.
|
72
72
|
|
@@ -85,13 +85,68 @@ You have two options, should the issue affect you (and it almost certainly will)
|
|
85
85
|
- For better security add something like an indexed boolean column indicating whether or not the user has been thus migrated and only perform old OID lookups on users which have not yet been migrated.
|
86
86
|
- If the user can't be found by either means, then they've not been connected to your system yet. Your existing handling path for such a condition applies.
|
87
87
|
|
88
|
-
|
88
|
+
#### Applications that handle multiple OAuth providers
|
89
89
|
|
90
90
|
If your user records contain users that have 'connected' to more than one kind of OAuth provider, then as well as the third party's UID being stored for future logins, you'll most likely have stored the OmniAuth provider name too so that the UID can be looked up in a provider's context (there's no guarantee, of course, that UIDs are unique *between providers* since they're entirely independent entities with their own strategies for allocating unique IDs).
|
91
91
|
|
92
92
|
In that case, you will need to migrate records from the old `azure_activedirectory_v2` name to `entra_id`. **Zero-downtime deployment of this change would be very hard since your codebase would need to update from the Azure ActiveDirectory V2 gem to the Entra ID gem with the migration running simultaneously**, so if you need to do such a migration, then you probably should plan for a small maintenance window. At the scheduled time, go into maintenance mode, migrate, deploy, and restore normal service. Even without this, though, the 'worst that can happen' (in theory!) would be temporary user login failures. Either the Entra gem will be causing you to look for a user with an `entra_id` provider but the migration to set this hasn't run yet, or the other way round, with the old gem looking for the old provider name but it's already updated.
|
93
93
|
|
94
|
-
|
94
|
+
#### Example migration code
|
95
|
+
|
96
|
+
Suppose you support multiple providers and your User table stores their chosen provider in a column `auth_provider`, with their UID in `auth_uid`. An (irreversible) database migration might do this:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
def up
|
100
|
+
add_column :users, :migrated_to_entra, :boolean
|
101
|
+
|
102
|
+
User
|
103
|
+
.where(auth_provider: 'azure_activedirectory_v2')
|
104
|
+
.update_all(
|
105
|
+
auth_provider: 'entra_id',
|
106
|
+
migrated_to_entra: false
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
def down
|
111
|
+
raise ActiveRecord::IrreversibleMigration
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
This means the `migrated_to_entra` column is only ever `false` for existing users that were linked using the V2 gem. Everything else will be at `NULL`. Now you lazy-move those users to the new UID format in the code you use to look up a user in your OmniAuth OAuth 2 callback handler, e.g. via a method such as this:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
# Here, "raw_info" comes from e.g.:
|
119
|
+
#
|
120
|
+
# request.env['omniauth.auth'].extra&.dig('raw_info') || {}
|
121
|
+
#
|
122
|
+
def find_user_for_omniauth(auth_provider:, auth_uid:, raw_info:)
|
123
|
+
found_user = User.find_by(
|
124
|
+
auth_provider: auth_provider,
|
125
|
+
auth_uid: auth_uid
|
126
|
+
)
|
127
|
+
|
128
|
+
if found_user.nil? && auth_provider == 'entra_id'
|
129
|
+
found = User.find_by(
|
130
|
+
auth_provider: 'entra_id',
|
131
|
+
auth_uid: raw_info['oid'],
|
132
|
+
migrated_to_entra: false
|
133
|
+
)
|
134
|
+
|
135
|
+
if found
|
136
|
+
found.update_columns(
|
137
|
+
auth_uid: auth_uid,
|
138
|
+
migrated_to_entra: true
|
139
|
+
)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
return found_user
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
147
|
+
Once there are no rows with a `migrated_to_entra` value of `false` for _active_ users, you will be able to drop the column and remove the lazy migration code.
|
148
|
+
|
149
|
+
### Other changes that might affect you
|
95
150
|
|
96
151
|
* If you refer to `OmniAuth::Strategies::AzureActivedirectoryV2` at all, then this becomes `OmniAuth::Strategies::EntraId` (note lower case "d").
|
97
152
|
* `base_azure_url` option renamed to just `base_url` with corresponding rename of `OmniAuth::Strategies::AzureActivedirectoryV2::BASE_AZURE_URL` to `OmniAuth::Strategies::EntraId::BASE_URL`.
|
@@ -13,6 +13,7 @@ module OmniAuth
|
|
13
13
|
|
14
14
|
DEFAULT_SCOPE = 'openid profile email'
|
15
15
|
COMMON_TENANT_ID = 'common'
|
16
|
+
AD_FS_TENANT_ID = 'adfs'
|
16
17
|
|
17
18
|
# The tenant_provider must return client_id, client_secret and,
|
18
19
|
# optionally, tenant_id and base_url.
|
@@ -135,9 +136,17 @@ module OmniAuth
|
|
135
136
|
|
136
137
|
# For multi-tenant apps (the 'common' tenant_id) it doesn't make any
|
137
138
|
# sense to verify the token issuer, because the value of 'iss' in the
|
138
|
-
# token depends on the 'tid' in the token itself.
|
139
|
+
# token depends on the 'tid' in the token itself. We should also skip
|
140
|
+
# for AD FS local instances, as we don't put a valid tenant ID in its
|
141
|
+
# place, but "adfs" (see AD_FS_TENANT_ID) instead.
|
139
142
|
#
|
140
|
-
|
143
|
+
do_not_verify = (
|
144
|
+
options.tenant_id.nil? ||
|
145
|
+
options.tenant_id == COMMON_TENANT_ID ||
|
146
|
+
options.tenant_id == AD_FS_TENANT_ID
|
147
|
+
)
|
148
|
+
|
149
|
+
issuer = if do_not_verify
|
141
150
|
nil
|
142
151
|
else
|
143
152
|
"#{options.base_url || BASE_URL}/#{options.tenant_id}/v2.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-entra-id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RIPA Global
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|