oidc-client.js 引发 "No authority passed" 错误

oidc-client.js raises "No authority passed" error

我是 SSO 的新手。最近我在关注一个使用 OIDC 的项目。我尝试使用 oidc-client 来解决问题。这是我的设置。(我删除了细节url,但它们是有效的)。

var mgr = new Oidc.UserManager({
    userStore: new Oidc.WebStorageStateStore({ store: window.localStorage }),
    metadata: {
      issuer: 'https://foo.com/',
      authorization_endpoint: 'https://foo.com/',
      userinfo_endpoint: 'https://foo.com/',
      end_session_endpoint: 'https://foo.com/',
      jwks_uri: 'https://foo.com/'
    },
    keys: [
      {
        'kty': 'RSA',
        'kid': 'some info',
        'use': 'some info',
        'n': 'some info',
        'e': 'some info'
      }
    ],
    client_id: 'aaaaa',
    redirect_uri: 'https://foo.com/',
    response_type: 'id_token token',
    scope: 'openid'
  })
  Oidc.Log.logger = console
  Oidc.Log.level = Oidc.Log.INFO
  mgr.signinRedirect()
    .then(function () { console.log('Hello') }).catch(function (err) {
      console.log(err)
    })

但它没有重定向到 authorization_endpoint。相反,它会引发如下错误

oidc-client.min.js?dd17:1 SigninRequest.ctor: No authority passed error @ oidc-client.min.js?dd17:1 SigninRequest @ oidc-client.min.js?dd17:3 (anonymous) @ oidc-client.min.js?dd17:3 Promise.then (async) createSigninRequest @ oidc-client.min.js?dd17:3 (anonymous) @ oidc-client.min.js?dd17:3 Promise.then (async) _signinStart @ oidc-client.min.js?dd17:3 signinRedirect @ oidc-client.min.js?dd17:3 onSubmit @ HelloWorld.vue?140d:71 click @ HelloWorld.vue?1f3f:21 invoker @ vue.runtime.esm.js?2b0e:2023 fn._withTask.fn._withTask @ vue.runtime.esm.js?2b0e:1822

我运行vue-cli环境下的代码。但我认为这不会导致问题。如果您遇到过类似的问题,请告诉我如何解决。谢谢。

请参阅 https://github.com/IdentityModel/oidc-client-js/wiki

中的所需设置

Required Settings

  • authority (string): The URL of the OIDC/OAuth2 provider.

从错误和你的代码看来你没有设置权限