只需要oidc中的ID令牌

问题描述 投票:0回答:1

我使用的是 oidc 中间件,配置如下:

oidcConfig = {
     issuer: configObj.oktaIssuer,
      client_id: global.configuration.oktaClientId,
      client_secret: global.configuration.oktaClientSecret,
      appBaseUrl: configObj.appBaseUrl,
      scope: 'openid profile',
      response_type: 'code',
      loginRedirectUri: configObj.appBaseUrl+'/authorization-code/callback',
      routes: {
        callback: { defaultRedirect: '/' },
        login: {
            path: '/signin',
         },
        loginCallback: {
            afterCallback: '/application/dashboard'
        }
    }
};

身份验证成功后,将创建一个包含访问令牌、ID 令牌和区域设置信息的 Cookie。

我的应用程序在注销时只需要 ID 令牌,不需要访问令牌和区域设置信息

我能够通过删除配置文件作为范围来删除区域设置信息,但仍然没有找到删除访问令牌的信息。任何线索将不胜感激。

nodeApp.use(
cookieSession({
    httpOnly: true,
    name: 'sample',
    keys: ['xxx', 'xxxx'],
    signed: true,
    // Cookie Options
    maxAge: 8 * 60 * 60 * 1000, // 8 hours
})
);
node.js oauth-2.0 openid-connect openid
1个回答
0
投票

在 Web 后端直接从数据库获取数据且不调用 API 的用例中,您可以使用仅返回 ID 令牌的流程。验证 ID 令牌后,应用程序将创建自己的基于 cookie 的会话。

为此,请配置

response_type=id_token
而不是
response_type=code

© www.soinside.com 2019 - 2024. All rights reserved.