首页 文章

Identity Server:使用访问令牌发送重置密码链接

提问于
浏览
0

我正在使用Identity Server 4实现身份验证和授权,以便用户可以访问我的API . 它使用OIDC和Implicit Flow来验证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和到期时间向我的数据库添加一个条目,然后将该链接发送给用户 . 当他请求重置密码链接时,我会对我的数据库进行验证并检查该条目是否仍然有效 .

目前,我的解决方案由两个服务器组成:Identity Server,Resource Server(API)和angular 2应用程序 . 用户必须获取令牌才能访问应用程序,然后获得访问API的授权 . 如果令牌无效,则无法调用API . 这是资源服务器验证令牌的方式:

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

            RequireHttpsMetadata = false
        });

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

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

1 回答

  • 0

    对于身份服务器3,密码重置不是身份服务器的责任 . 您应该依赖底层成员资格提供程序系统(asp.net identity或membershipreboot)来重置密码 . 通过这种方式,您可以在身份服务器主机中托管重置屏幕 .

相关问题