标签: oidc-client-js

没有用户使用身份服务器和 javascript 的 oidc 客户端在 signinSilentCallback 中

我在以下代码中得到用户未定义。

我已经从 MVC 验证了用户。

但是当我使用 signinSilentCallback 获取该用户的详细信息时,它在 js 中使用 oidc-client 变得未定义。

它也没有给出任何错误。

        var mgr = new UserManager({
                    authority: "http://localhost:5000",
                    client_id: "js",
                    redirect_uri: "http://localhost:50144/signin-oidc",
                    silent_redirect_uri: "http://localhost:50144/signin-oidc",
                    response_type: "id_token token",
                    post_logout_redirect_uri: "http://localhost:50144/signout-callback-oidc",
                });

        mgr.signinSilentCallback().then(function (user) {

            //**Here user is undefined.**
            axios.defaults.headers.common['Authorization'] = "Bearer " + user.access_token;

        });
Run Code Online (Sandbox Code Playgroud)

在 Identityserver 4 中,客户端定义如下。

new Client
                {
                    ClientId = "js",
                    ClientName = "js",
                    ClientUri = "http://localhost:50144",

                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    RequireClientSecret = false,
                    AccessTokenType = AccessTokenType.Jwt,

                    RedirectUris = 
                    {
                        "http://localhost:50144/signin-oidc",
                    },

                    PostLogoutRedirectUris = …
Run Code Online (Sandbox Code Playgroud)

openid-connect identityserver4 oidc-client-js

9
推荐指数
2
解决办法
8462
查看次数

IdentityServer4 - 如何实施模拟

我要求允许我们的内部支持用户冒充我们的客户用户.

我目前正在使用IdentityServer4,Implicit Flow和OIDC Client.

迄今为止找到的资源.

鉴于在线资源有限,我是否可以/应该使用IdentityServer4实施模拟?

impersonation asp.net-core identityserver4 implicit-flow oidc-client-js

8
推荐指数
2
解决办法
1816
查看次数

在oidc-client-js中回调后没有响应状态

我认为这是与角度5.2.8和6相关的错误.角度5.2.7工作正常.我创建一个ng5分支并更新角度到最新的5.2.8和错误com!任何人都可以指导我使用oidc-client-js进行角度5.2.8和更高版本的样本?

openid-connect oidc-client-js angular

8
推荐指数
2
解决办法
2984
查看次数

Identity Server 4 Silent Renew ErrorResponse: login_required

我已经从redux-oidc-example克隆了 repo并且它在大多数情况下都有效,但是几个小时后它给出了以下错误:

操作负载:ErrorResponse: login_required
at new e (oidc-client.min.js:1)
at t [as _processSigninParams] (oidc-client.min.js:1)
at t [as validateSigninResponse] (oidc-client.min. js:1)
在 oidc-client.min.js:1

UserManager.js 看起来像这样:

const userManagerConfig = {
  client_id: 'js.dev',
  client_secret: 'secret',
  redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/callback`,
  response_type: 'id_token token',
  scope: 'openid email profile role offline_access',
  authority: 'http://localhost:8080',
  silent_redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/silent_renew.html`,
  automaticSilentRenew: true,
  filterProtocolClaims: true,
  loadUserInfo: true
};
Run Code Online (Sandbox Code Playgroud)

和我的身份服务器配置:

{
        "Enabled": true,
        "ClientId": "js.dev",
        "ClientName": "Javascript Client",
        "ClientSecrets": [ { "Value": "K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=" } ],
        "AllowedGrantTypes": …
Run Code Online (Sandbox Code Playgroud)

identityserver4 oidc-client-js

7
推荐指数
2
解决办法
6171
查看次数

什么是ProfileService /何时执行ProfileService?

我一直在玩IdentityServer4.绝对喜欢它.

我一直在浏览你网站上的教程,特别是https://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html

我创建了一个Profile Service,它执行以下操作:

public class ProfileService : IProfileService
{
    public Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        context.IssuedClaims.Add(new Claim("test-claim", "test-value"));
        return Task.FromResult(0);
    }

    public Task IsActiveAsync(IsActiveContext context)
    {
        context.IsActive = true;

        return Task.FromResult(0);
    }
}
Run Code Online (Sandbox Code Playgroud)

这很好用,我的自定义声明在我的JS客户端的日志窗口中可见.

我在它上面设置了一个断点,只是为了检查上下文中的内容,我注意到它被击中了两次.呼叫者性质ClaimsProviderAccessTokenUserInfoEndpoint分别.为什么是这样?

在我的天真中,我profile从我的js客户端删除了范围,并且在oidc-js配置中也删除了配置文件范围,然后设置loadUserInfo: falseProfileService的仍然被调用两次.

如果我的最终目标是根据数据库中的参数设置声明,我真的不想两次做这个操作,是吗?(真正的问题 - 我不知道)."解决方案"只是将它们设置在"ClaimsProviderAccessToken"上,但有一些东西告诉我,ProfileServices会被调用两次,并且它在两次运行中设置声明的重要性.

Ps我认为这里有一个拼写错误https://github.com/IdentityServer/IdentityServer4/blob/dev/docs/quickstarts/8_entity_framework.rst这部分不应该是"Microsoft.EntityFrameworkCore.Tools.DotNet" ClaimsProviderAccessToken吗?而不是"Microsoft.EntityFrameworkCore.Tools"我认为为一些如此微不足道的事情创建一个新问题是不恰当的,而不一定是错的!

c# asp.net asp.net-core identityserver4 oidc-client-js

6
推荐指数
1
解决办法
2913
查看次数

身份服务器4中的静默令牌更新与js客户端应用程序无法正常工作

我正在与身份服务器4一起为企业架构中的不同应用提供身份服务。

使用oidc-client.js在身份服务器4应用程序中使用隐式流注册了SPA应用程序,并且正在运行。

但是问题在于令牌更新,需要长时间保留用户登录名而又不要求用户再次登录。

为此,请使用以下配置实施静默令牌续订。

var config = {
    authority: "http://localhost:5000",
    client_id: "jswebclient",
    redirect_uri: "http://localhost:5003/callback.html",
    response_type: "id_token token",
    scope: "openid profile api1",
    post_logout_redirect_uri: "http://localhost:5003/loggedout.html",
    automaticSilentRenew: true,
    silent_redirect_uri : "http://localhost:5003/callback.html" }; 
Run Code Online (Sandbox Code Playgroud)

var mgr = new Oidc.UserManager(config);

使用上述配置时,会发生自动续订,但没有按预期进行静默续订,正在发生将页面重定向到重定向uri的完整页面,以处理来自身份服务器的响应。

例如:index.html是我的实际页面,在其中进行静默更新,而callback.html是重定向uri,index.html重定向到callback.html,然后更新,然后重定向回到index.html,并附有实际的网络日志下面,在此处输入图片说明

任何人都可以帮助我解决问题以使更新无声发生吗?

access-token identityserver4 implicit-flow oidc-client-js

6
推荐指数
1
解决办法
4749
查看次数

Oidc-Client js-框架窗口超时-静默登录

app.jsI hava中,AuthorizationInterceptor它检查用户是否已登录。当用户令牌到期时,它会遇到err条件和错误Frame window timed out(请参见下文),然后进入重定向循环。我想进行无提示登录,但我想iframe出错了。我看不到它曾经重定向到silent-callback.html-仅命中callback.html

app.factory("AuthorizationInterceptor", ['$q', '$injector', '$rootScope', '$window', 'authService', function ($q, $injector, $rootScope, $window, authService) {

    var request = function (requestSuccess) {

        var currentTime = Math.floor(Date.now() / 1000);

                var deferred = $q.defer();
                var oidcManager = window.translation.oidcUserManager;

                oidcManager.getUser().then(function (u) {
                    if (u) {

                        if (u['expires_at'] < currentTime + 10) {
                            oidcManager.signinSilent()
                                .then(function (user) {
                                    requestSuccess.headers['Authorization'] = "Bearer " + user["access_token"];
                                    deferred.resolve(requestSuccess);
                                }, function (err) {
                                    console.log('getuser error' + err); …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs oidc-client-js

6
推荐指数
1
解决办法
1220
查看次数

针对Auth0的oidc-client-js的signoutRedirect不返回任何结束会话终结点

我已经成功使用了Brock Allen 的oidc-client-js库,以Auth0作为我的身份提供者对我的SPA应用程序进行了身份验证。但是,当我尝试使用该库将用户注销时mgr.signoutRedirect({state: "my test"}),会收到错误消息:no end session endpoint

在此处输入图片说明

查看元数据端点会发现存在一个撤销端点。

我已经像这样配置oidc-client-js库:

var settings = {
   authority: 'https://susqsofttest.auth0.com/.well-known/openid-configuration',
   client_id: 'my client id',
   redirect_uri: 'http://localhost:8080/signin-oidc',
   post_logout_redirect_uri: 'http://localhost:8080/logout',
   response_type: 'id_token token',
   scope: 'openid profile email',
   revokeAccessTokenOnSignout: true,
   automaticSilentRenew: true,
   filterProtocolClaims: true,
   loadUserInfo: true
};
var mgr = new UserManager(settings);
Run Code Online (Sandbox Code Playgroud)

有什么我想念的想法吗?

auth0 oidc-client-js

6
推荐指数
2
解决办法
2577
查看次数

OIDC和PWA(添加到主屏幕)

更新:基本上与Standalone PWA相同的问题会破坏登录但在iOS上.

如果您将Web应用程序添加到主屏幕,则Android上的Chrome会在浏览器中与同一域共享本地存储.您可以通过访问https://wilfrem.github.io/add_to_homescreen_test/进行测试,然后添加到主屏幕,并在主屏幕上打开时看到您具有相同的ID.(我做了Nexus 5x)

如果您在iOS Safari中执行相同操作,则会获得新ID.(我做了iPod iOS 12.1.1)

oidc-client-js库在本地存储中设置会话引用,然后在Web应用程序的signin回调中调用它.因此,如果您尝试从iOS主屏幕上打开的Web应用程序登录,它会在Safari中打开OP(oidc提供程序),然后重定向回Web应用程序的URL,但在Safari中不是从主屏幕Web应用程序打开的,因此,您可以获得不同的本地存储空间:

存储中找不到匹配状态

如果本地存储不在同一个域中共享,您应该如何使用oidc与从主屏幕Web应用程序打开的iOS?或者,当重定向回Web应用程序时,如何让iOS重新打开正确的窗口(从主屏幕打开的窗口)?或者,当我首先导航到OP(oidc提供商)时,如何让iOS永远不会离开全屏应用?

编辑:

这是解释问题的叙述.

  • 打开 my.app.com
  • 添加到主屏幕
  • 从主屏幕打开应用程序
  • 单击登录按钮
  • 登录按钮电话 UserManager.signinRedirect()
  • UserManager.signinRedirect() 电话 OidcClient.createSigninRequest()
  • OidcClient.createSigninRequest()在本地存储中存储登录状态并导航以在Androidmy.op.com 查看 打开Chrome选项卡,并在iOS上打开Safarimy.op.commy.op.com
  • 在操作上完成登录过程
  • op重定向到my.app.com/signin-callback.html 这里是问题所在

my.app.com/signin-callback.html主屏幕上打开的应用程序中打开Android ,在iOS上它保留在Safari中.所以你得到:

存储中找不到匹配状态

我没有遇到错误,根据发生的错误是完全可以预料到的,我只是不知道如何让Safari以一种可以与库一起工作的方式运行.

如果它相关这是我的manifest.json

{
  "name": "omitted",
  "short_name": "omitted",
  "theme_color": "#omitted",
  "background_color": "#omitted",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",
  "icons": [
    {
      "src": "omitted",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "omitted",
      "sizes": "512x512", …
Run Code Online (Sandbox Code Playgroud)

iphone-standalone-web-app openid-connect progressive-web-apps oidc-client-js

6
推荐指数
1
解决办法
475
查看次数

OidcClient.readSigninResponseState:在存储中找不到匹配的状态 - oidc-client-js (Angular)

我正在使用oidc-client 库在我的 Angular(9) 应用程序中与 Azure AD 集成。signinRedirect()&signinSilent()功能按预期工作。但是对于signinPopup()它在浏览器 url 片段中成功获取了访问令牌,但它引发了下面提到的错误

app.component.ts:83 错误:在 oidc-client.min.js:1 的存储中找不到匹配的状态

令人惊讶的是,在 signin-callback.html 中,当我将 response_type 作为 query 传递时var userManager = new Oidc.UserManager({response_mode: "query"});,登录弹出成功但登录重定向失败抱怨

错误:无状态响应

我最初关注了这篇文章

这是我的服务代码:

import { Injectable } from '@angular/core';
import { UserManager, UserManagerSettings, User } from 'oidc-client';

import { environment } from 'src/environments/environment';

@Injectable({
  providedIn: 'root'
})
export class AuthService {
  private userManager: UserManager;

  constructor() {
    this.instantiate();
  }

  private instantiate() …
Run Code Online (Sandbox Code Playgroud)

local-storage openid-connect oidc-client-js angular oidc-client

6
推荐指数
1
解决办法
5024
查看次数