|
1 | | -import { decodeProtectedHeader } from 'jose'; |
2 | | - |
3 | 1 | import presence from '../helpers/validate_presence.js'; |
4 | 2 | import getClientAuth from '../shared/client_auth.js'; |
5 | 3 | import noCache from '../shared/no_cache.js'; |
6 | 4 | import instance from '../helpers/weak_cache.js'; |
7 | 5 | import { urlencoded as parseBody } from '../shared/selective_body.js'; |
8 | 6 | import rejectDupes from '../shared/reject_dupes.js'; |
9 | 7 | import paramsMiddleware from '../shared/assemble_params.js'; |
10 | | -import { InvalidRequest, UnsupportedTokenType } from '../helpers/errors.js'; |
| 8 | +import { InvalidRequest } from '../helpers/errors.js'; |
| 9 | +import rejectStructuredTokens from '../shared/reject_structured_tokens.js'; |
11 | 10 |
|
12 | 11 | const introspectable = new Set(['AccessToken', 'ClientCredentials', 'RefreshToken']); |
13 | 12 | const JWT = 'application/token-introspection+jwt'; |
@@ -63,6 +62,8 @@ export default function introspectionAction(provider) { |
63 | 62 | await next(); |
64 | 63 | }, |
65 | 64 |
|
| 65 | + rejectStructuredTokens, |
| 66 | + |
66 | 67 | async function jwtIntrospectionResponse(ctx, next) { |
67 | 68 | if (jwtIntrospection.enabled) { |
68 | 69 | const { client } = ctx.oidc; |
@@ -97,15 +98,6 @@ export default function introspectionAction(provider) { |
97 | 98 | async function renderTokenResponse(ctx) { |
98 | 99 | const { params } = ctx.oidc; |
99 | 100 |
|
100 | | - let tokenIsJWT; |
101 | | - try { |
102 | | - tokenIsJWT = !!decodeProtectedHeader(params.token); |
103 | | - } catch {} |
104 | | - |
105 | | - if (tokenIsJWT) { |
106 | | - throw new UnsupportedTokenType('Structured JWT Tokens cannot be introspected via the introspection_endpoint'); |
107 | | - } |
108 | | - |
109 | 101 | ctx.body = { active: false }; |
110 | 102 |
|
111 | 103 | let token; |
|
0 commit comments