Skip to content

Commit 8afc2cc

Browse files
committed
feat: support Authorization Code Flow
1 parent dada968 commit 8afc2cc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

playground/nuxt.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default defineNuxtConfig({
4141
issuer: 'http://192.168.26.114:8080/realms/test', // change to your OP addrress
4242
clientId: 'testClient',
4343
clientSecret: 'cnuLA78epx8s8vMbRxcaiXbzlS4u8bSA',
44-
// callbackUrl: 'http://192.168.26.114:3000/oidc/callback', // optional
44+
callbackUrl: 'http://192.168.26.114:3000/oidc/callback', // optional
4545
scope: [
4646
'email',
4747
'profile',
@@ -50,7 +50,7 @@ export default defineNuxtConfig({
5050
},
5151
config: {
5252
debug: true,
53-
response_type: 'id_token token',
53+
response_type: 'code',
5454
secret: 'oidc._sessionid',
5555
cookie: { loginName: '' },
5656
cookiePrefix: 'oidc._',

src/runtime/server/routes/oidc/callback.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ export default defineEventHandler(async (event) => {
4343
res.end()
4444
} else if (params.code) {
4545
// Authorization Code Flow: code -> access_token
46-
logger.debug('[CALLBACK]: has code in params')
47-
const callBackUrl = op.callbackUrl.replace('cbt', 'callback')
48-
const tokenSet = await issueClient.callback(callBackUrl, params, { nonce: sessionid })
46+
logger.debug('[CALLBACK]: has code in params, code:' + params.code)
47+
const tokenSet = await issueClient.callback(callbackUrl, params, { nonce: sessionid })
48+
// logger.info('received and validated tokens %j', tokenSet)
49+
// logger.info('validated ID Token claims %j', tokenSet.claims())
4950
if (tokenSet.access_token) {
5051
await getUserInfo(tokenSet.access_token)
5152
}

0 commit comments

Comments
 (0)