如何将用户重定向到IdentityServer4中的注册页面? [英] How to redirect user to registration page in IdentityServer4?

查看:252
本文介绍了如何将用户重定向到IdentityServer4中的注册页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已基于快速入门的第六步使用ASP实现了应用安全性.NET Core Identity" ,因此登录/注册表单是在auth上实现的.权威方面.现在,对于任何安全页面用户,重定向到auth上的登录页面.权威.在基于asp.net核心基于mvc的客户端应用程序上,我在标头中具有登录/注册链接.我如何将用户重定向到从客户端站点到auth的注册页面.权威网站?

I have implemented app security based on 6th step of quick start "Using ASP.NET Core Identity", so login/register forms implemented at auth. authority side. Now for any secured page user redirected to login page on auth. authority. On my asp.net core mvc based client app i have login / register links in header. How can i redirect a user to registration page from client site to auth. authority site ?

推荐答案

首先,我建议为客户端应用程序中的未授权用户创建单个链接:Register or Login.无需将用户发送到专门用于注册的位置,而是将登录名或新注册的选择移到Identity Server登录页面中.

First of all, I recommend creating a single link for unauthorized users in your client application: Register or Login. Rather than sending the user somewhere specifically for registration, move the choice of login or new registration into the Identity Server login page.

总是要在登录流程的上下文中将用户发送到Identity Server.如果您允许第三方IdP(Google等),这对新用户也更有意义:他们可以在一个页面上使用第三方IdP 创建一个新帐户,或者注册一个新的本地帐户. (当您处理外部登录时,将IdP电子邮件地址与用户数据库进行比较.如果电子邮件地址是新的,则用户是新的.如果电子邮件地址是来自另一个IdP的文件,则您可能要取消登录并发出警告通过电子邮件向用户表明他们选择了错误的IdP.)

You always want to send the user to Identity Server within the context of a login flow. If you allow third-party IdPs (Google etc) this also makes more sense to a new user: from a single page they can create a new account with a third-party IdP or register a new local account. (When you process an external login, compare the IdP email address against your user database. If the email address is new, the user is new. If the email address is on file from another IdP, you probably want to cancel the login and warn the user by email that they chose the wrong IdP.)

从那里开始,您只是在Identity Server中进行重定向以完成注册和登录,并且只要您注意跟踪该返回URL,一切都会正常工作.

From there, you're just doing redirection within Identity Server to complete registration and login, and everything will work as long as you're careful to keep track of that return URL.

这篇关于如何将用户重定向到IdentityServer4中的注册页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆