从IdentityServer3登录页面中的客户端获取重定向链接

编程入门 行业动态 更新时间:2024-10-21 07:42:15
本文介绍了从IdentityServer3登录页面中的客户端获取重定向链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想从登录页面中IdentityServer3的Identity中的客户端获取redirectUrl. 对于EX:我有一个"localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout"链接 当我点击它时,我将被重定向到IndentityServer中的登录页面,我需要获取上面的重定向链接( localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout ) 在

I would like to get redirectUrl from a client in Identity in IdentityServer3 in the login page. for EX: I have a "localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout" link when I hit it , I will be redirected to a login page in IndentityServer and I need to get redirect link above (localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout) in

public class CustomViewService: DefaultViewService { private gtoken _gtoken; public CustomViewService(DefaultViewServiceOptions config, IViewLoader viewLoader, gtoken gtoken) : base(config, viewLoader) { _gtoken = gtoken; } public override Task<Stream> Login(LoginViewModel model, SignInMessage message) { //TODO need to get redirect link here return base.Login(model, message); } }

这是我的客户端配置:

public void Configuration(IAppBuilder app) { // turn off any default mapping on the JWT handler AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub"; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); app.Map("/api", idsrvApp => { idsrvApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { Authority = "localhost:5001", ValidationMode = ValidationMode.Local, //set to validation endpoint if we want to support JWT revocation RequiredScopes = new[] { "payment" } }); }); Func<IOwinContext, bool> notApiRequest = (ctx) => { return !ctx.Request.Path.StartsWithSegments(new PathString("/api")); }; app.MapWhen(notApiRequest, idsrvApp => { idsrvApp.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies", CookieName = Constants.AUTH_COOKIE_NAME }); idsrvApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { Authority = "localhost:5001", ClientId = "06de763b-ad15-4225-a147-9f7b5da61cdf", RedirectUri = "mylocal", ResponseType = "id_token", Scope = "openid", SignInAsAuthenticationType = "Cookies", }); }); }

推荐答案

我不明白您为什么要在此处进行重定向.我看不出逻辑.

I don't understand why would you want the redirect to happen there. I don't see the logic.

您已经阅读了identityServer3的文档吗?您将在此处看到

Have you read the documentation for identityServer3? You'll see there:

GET/connect/authorize?client_id = client1& scope = openid电子邮件api1& response_type = id_token令牌& redirect_uri = localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout

*链接: identityserver.github.io/Documentation/docsv2 /endpoints/authorization.html

这意味着,当您看到用户未登录时,会将其发送到身份服务器的登录页面(即使上面的HTTP GET方法链接到端点,身份服务器也会显示登录页面),并在登录页面的请求中发送重定向网址.只需确保该客户端允许使用重定向网址即可(请查看文档).

It means, when you see that the user is not logged in you send him to the login page of your identity server (even though the HTTP GET method above links to an endpoint, the identity server will show a login page), and in the request to the login page you would send an redirect url. Just make sure the redirect url is allowed for that client (check the documentation).

p.s.不建议将API和身份服务器保留在同一项目中!

p.s. It is not recommended to keep the API and the identity server in the same project!

更多推荐

从IdentityServer3登录页面中的客户端获取重定向链接

本文发布于:2023-11-17 02:02:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608397.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   重定向   页面   链接

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!