【问题标题】:Identity Server: Send a reset password link with an access token身份服务器:发送带有访问令牌的重置密码链接
【发布时间】:2019-02-28 19:25:09
【问题描述】:

我正在使用 Identity Server 4 来实现身份验证和授权,以便用户可以访问我的 API。它使用带有隐式流的 OIDC 来验证 angular2 客户端应用程序:

                ClientName = "angular2client",
                ClientId = "angular2client",
                AccessTokenType = AccessTokenType.Jwt,               
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,
                RedirectUris = new List<string>
                {
                    "http://localhost:5000" //we have to provide https for all the urls

                },
                PostLogoutRedirectUris = new List<string>
                {
                    "http://localhost:5000/Unauthorized"
                },
                AllowedCorsOrigins = new List<string>
                {
                    "http://localhost:5000",

                },
                AllowedScopes = new List<string>
                {
                   "openid",
                   "resourceAPIs"

                }

我计划通过向用户发送电子邮件链接来为用户提供重置密码选项。在传统的实现中,我会在我的数据库中添加一个带有自定义哈希、userId 和到期期限的条目,然后将该链接发送给用户。当他请求重置密码链接时,我会根据我的数据库对其进行验证,并检查该条目是否仍然有效。

目前,我的解决方案由两台服务器组成:身份服务器、资源服务器 (API) 和 Angular 2 应用程序。用户必须获得令牌才能访问应用程序,然后才能获得访问 API 的授权。如果令牌无效,他们将无法调用 API。 这是资源服务器验证令牌的方式:

        app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
        {
            Authority = "http://localhost:44311",
            ScopeName = "resourceAPIs",

            RequireHttpsMetadata = false
        });

如果我想使用 Identity Server 4 执行此操作,并发送带有令牌的电子邮件链接,允许他访问更改密码 API。我应该对客户进行哪些更改?

我是否应该添加另一个有权访问这个“重置密码 API”的客户端,以防止他使用相同的令牌访问资源 API。这种实施的最佳实践是什么?

【问题讨论】:

    标签: access-token identityserver3 thinktecture-ident-server forgot-password identityserver4


    【解决方案1】:

    对于身份服务器 3,密码重置不是身份服务器的责任。您应该依靠底层会员提供系统(asp.net 身份或会员重启)来重置密码。顺便说一句,您可以在身份服务器主机中托管重置屏幕。

    【讨论】:

      猜你喜欢
      • 2017-03-08
      • 2017-09-10
      • 2020-02-29
      • 2022-01-11
      • 2015-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      相关资源
      最近更新 更多