@muze-nl/metro-oidc 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +312 -49
- package/dist/browser.js.map +4 -4
- package/dist/browser.min.js +3 -3
- package/dist/browser.min.js.map +3 -3
- package/package.json +4 -4
- package/src/oidcmw.mjs +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/metro-oidc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "oidc client middleware for @muze-nl/metro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": [
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@muze-nl/assert": "^0.6.0",
|
|
56
|
-
"@muze-nl/metro-core": "^0.
|
|
57
|
-
"@muze-nl/metro-middleware": "^0.
|
|
58
|
-
"@muze-nl/metro-oauth2": "^0.
|
|
56
|
+
"@muze-nl/metro-core": "^0.9.0",
|
|
57
|
+
"@muze-nl/metro-middleware": "^0.9.0",
|
|
58
|
+
"@muze-nl/metro-oauth2": "^0.9.0",
|
|
59
59
|
"jose": "^6.2.3"
|
|
60
60
|
},
|
|
61
61
|
"exports": {
|
package/src/oidcmw.mjs
CHANGED
|
@@ -24,6 +24,7 @@ export default function oidcmw(options={}) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
options = Object.assign({}, defaultOptions, options)
|
|
27
|
+
const requestedClientInfo = options.client_info
|
|
27
28
|
|
|
28
29
|
assert(options, {
|
|
29
30
|
client: Required(instanceOf(metro.client().constructor)), // required because it is set in defaultOptions
|
|
@@ -40,7 +41,10 @@ export default function oidcmw(options={}) {
|
|
|
40
41
|
options.openid_configuration = options.store.get('openid_configuration')
|
|
41
42
|
}
|
|
42
43
|
if (!options.client_info?.client_id && options.store.has('client_info')) {
|
|
43
|
-
|
|
44
|
+
const storedClientInfo = options.store.get('client_info')
|
|
45
|
+
if (clientInfoMatchesRequest(storedClientInfo, requestedClientInfo)) {
|
|
46
|
+
options.client_info = storedClientInfo
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
return async (req, next) => {
|
|
@@ -169,6 +173,17 @@ export default function oidcmw(options={}) {
|
|
|
169
173
|
|
|
170
174
|
}
|
|
171
175
|
|
|
176
|
+
function clientInfoMatchesRequest(storedClientInfo, requestedClientInfo) {
|
|
177
|
+
if (!storedClientInfo?.client_id) {
|
|
178
|
+
return false
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(requestedClientInfo?.redirect_uris)) {
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
const storedRedirectUris = new Set(storedClientInfo.redirect_uris || [])
|
|
184
|
+
return requestedClientInfo.redirect_uris.every(uri => storedRedirectUris.has(uri))
|
|
185
|
+
}
|
|
186
|
+
|
|
172
187
|
export function isRedirected() {
|
|
173
188
|
return oauth2.isRedirected()
|
|
174
189
|
}
|