首页 > 解决方案 > 从身份服务器 url 读取参数

问题描述

我在 IIS 服务器上托管的 asp.net 中有一个身份服务器,并且我已经注册了一个这样的客户端

 public static IEnumerable<Client> Get()
 {
      return new[]{
            new Client
            {
                Enabled = true,
                ClientName = "MyClient",
                ClientId = " uniqueclientId",
                Flow = Flows.Implicit,
                AccessTokenType = AccessTokenType.Jwt,

                RedirectUris ={"http://localhost:3000/callback"},

                PostLogoutRedirectUris = new List<string>
                {
                    clientBaseURL+"/index.html"
                },

                AllowedCorsOrigins = new List<string>
                {
                    clientBaseURL
                },

                AllowAccessToAllScopes = true,
                AccessTokenLifetime = TokenExpiryTimeInSeconds,
                AllowAccessTokensViaBrowser = true,
                AlwaysSendClientClaims = true,
                RequireConsent=false
            },
            new Client {....}

     }

我正在使用护照包在我的nodejs应用程序中调用它。身份验证后,我在回调 url 中收到的值是http://localhost:3000/callback#id_token=someidtoken&access_token=someaccesstoken我试图读取的值

app.get('/callback',passport.authenticate('openidconnect', { failureRedirect: '/login' }),
  function(req, res) {
    console.log(req)
    res.redirect('/');
});

这是来自 strategy.js 的一部分passport-openidconnect

meta.callbackURL = callbackURL;

  var params = self.authorizationParams(options);
  params['response_type'] =["id_token token"];
  params['client_id'] = config.clientID;
  if (callbackURL) { params.redirect_uri = callbackURL; }
  var scope = options.scope || self._scope;
  if (Array.isArray(scope)) { scope = scope.join(' '); }
  if (scope) {
    params.scope = 'openid ' + scope;
  } else {
    params.scope = 'openid';
  }

但是我不能点击这个 URL,因为查询字符串中有参数(#在 url 中也有一个)。如何在我的节点 js 应用程序中阅读此内容?我错过了什么吗?

标签: c#node.jsidentityserver3

解决方案


推荐阅读