【问题标题】:Issuing JWT access token using node-oidc-provider in authorization_code workflow在 authorization_code 工作流程中使用 node-oidc-provider 颁发 JWT 访问令牌
【发布时间】:2022-08-02 15:56:53
【问题描述】:

以下是我对 oidc 提供程序的配置。 我在功能下添加了资源指标。但它根本不起作用。如何在 authentication_code 工作流程中使用 node-oidc-provider 颁发 JWT 访问令牌?

提供程序版本为 7.11.4。

clients: [
    {
      client_id: \'0oa5pa23mzKPWYtvV5d7\',
      redirect_uris: [\'https://jwt.io\', \'http://localhost:3000/login/callback\'], // using jwt.io as redirect_uri to show the ID Token contents
      response_types: [\'code\'],
      application_type: \'web\',
      token_endpoint_auth_method: \'none\',
      scope: \'openid offline_access profile email\',
      grant_types: [\'authorization_code\', \'refresh_token\'],
    },
  ],
  routes: {
    authorization: \'/oauth2/v1/authorize\',
    token: \'/oauth2/v1/token\',
    revocation: \'/oauth2/v1/revoke\',
    userinfo: \'/oauth2/v1/userinfo\',
  },
  clientBasedCORS(ctx, origin, client) {
    if (client.clientId === \'0oa5pa23mzKPWYtvV5d7\' && origin === \'http://localhost:3000\') {
      return true;
    }


    return false;
  },
  pkce: {
    required: () => true,
  },
  interactions: {
    url(ctx, interaction) { // eslint-disable-line no-unused-vars
      return `/interaction/${interaction.uid}`;
    },
  },
  cookies: {
    keys: [\'some secret key\', \'and also the old rotated away some time ago\', \'and one more\'],
  },
  claims: {
    address: [\'address\'],
    email: [\'email\', \'email_verified\'],
    phone: [\'phone_number\', \'phone_number_verified\'],
    profile: [\'birthdate\', \'family_name\', \'gender\', \'given_name\', \'locale\', \'middle_name\', \'name\',
      \'nickname\', \'picture\', \'preferred_username\', \'profile\', \'updated_at\', \'website\', \'zoneinfo\'],
  },
  features: {
    resourceIndicators: {
      getResourceServerInfo: () => ({
        audience: \'solid\',
        accessTokenTTL: 2 * 60 * 60, // 2 hours
        accessTokenFormat: \'jwt\',
        jwt: {
          sign: { alg: \'ES256\' },
        },
      }),
    },
  },

    标签: node-oidc-provider


    【解决方案1】:

    defaultResource 也需要更新。在 jwt 的情况下,此函数必须返回正确的值。默认情况下,它返回未定义。

            resourceIndicators: {
                defaultResource: (ctx, client, oneOf) => {
                    if (oneOf) return oneOf;
                    return client['access_token_type'] === 'opaque' ? undefined : `https://${clientId}.com`;
                },
                getResourceServerInfo: (ctx, resourceIndicator, client) => {
                    return ({
                        scope: client.scope,
                        accessTokenTTL: 2 * 60 * 60,
                        accessTokenFormat: 'jwt',
                    });
                }
            },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-15
      • 2022-08-21
      • 2021-04-30
      • 2021-08-23
      • 1970-01-01
      • 2021-09-17
      • 2021-10-23
      • 2022-07-21
      相关资源
      最近更新 更多