@muze-nl/metro-oidc 0.1.5 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muze-nl/metro-oidc",
3
- "version": "0.1.5",
3
+ "version": "0.3.0",
4
4
  "description": "oidc client middleware for @muze-nl/metro",
5
5
  "type": "module",
6
6
  "source": [
@@ -48,7 +48,7 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@muze-nl/assert": "^0.3.3",
51
- "@muze-nl/metro": "^0.5.5",
52
- "@muze-nl/metro-oauth2": "^0.3.5"
51
+ "@muze-nl/metro": "^0.6.0",
52
+ "@muze-nl/metro-oauth2": "^0.5.0"
53
53
  }
54
54
  }
@@ -89,7 +89,7 @@ export default async function oidcDiscovery(options={}) {
89
89
  // note: this allows path components in the options.issuer url
90
90
  configURL
91
91
  )
92
- const openid_config = response.body[Symbol.metroSource]
92
+ const openid_config = response.data
93
93
  assert(openid_config, openid_provider_metadata)
94
94
 
95
95
  // https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation
@@ -63,7 +63,7 @@ export default async function register(options)
63
63
  .post(options.registration_endpoint, {
64
64
  body: options.client_info
65
65
  })
66
- let info = response.body
66
+ let info = response.data
67
67
  if (!info.client_id || !info.client_secret) {
68
68
  throw metro.metroError('metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned', response)
69
69
  }
package/src/oidcmw.mjs CHANGED
@@ -67,6 +67,7 @@ export default function oidcmw(options={}) {
67
67
 
68
68
  // now initialize an oauth2 client stack, using options.client as default
69
69
  // with forceAuthentication: true
70
+ const scope = options.scope || 'openid'
70
71
  const oauth2Options = Object.assign(
71
72
  {
72
73
  site: options.issuer,
@@ -75,11 +76,12 @@ export default function oidcmw(options={}) {
75
76
  oauth2_configuration: {
76
77
  client_id: options.client_info.client_id,
77
78
  client_secret: options.client_info.client_secret,
78
- code_verifier: false, //FIXME: detect pkce support
79
79
  grant_type: 'authorization_code',
80
+ response_type: 'code',
81
+ response_mode: 'query',
80
82
  authorization_endpoint: options.openid_configuration.authorization_endpoint,
81
83
  token_endpoint: options.openid_configuration.token_endpoint,
82
- scope: options.openid_configuration.scope || 'openid',
84
+ scope, //FIXME: should only use scopes supported by server
83
85
  redirect_uri: options.client_info.redirect_uris[0] //FIXME: find the best match?
84
86
  }
85
87
  }
@@ -87,6 +89,7 @@ export default function oidcmw(options={}) {
87
89
  )
88
90
 
89
91
  const dpopOptions = {
92
+ site: options.issuer,
90
93
  authorization_endpoint: options.openid_configuration.authorization_endpoint,
91
94
  token_endpoint: options.openid_configuration.token_endpoint,
92
95
  dpop_signing_alg_values_supported: options.openid_configuration.dpop_signing_alg_values_supported
@@ -96,6 +99,7 @@ export default function oidcmw(options={}) {
96
99
  const res = await next(req)
97
100
  const contentType = res.headers.get('content-type')
98
101
  if (contentType?.startsWith('application/json')) {
102
+ //FIXME; check that this is actually the token endpoint
99
103
  const res2 = res.clone() // otherwise res.body can't be read again
100
104
  try {
101
105
  let data = await res2.json()