我正在根据Katana项目中的其他示例为OpenID Connect授权代码流编写自己的OWIN中间件.
作为其中的一部分,我必须构造一些URI,例如重定向URI和返回URL.
Katana中的其他示例通过连接当前请求中的部分来完成此操作,例如在CookieAuthenticationHandler中
loginUri = Request.Scheme + Uri.SchemeDelimiter + Request.Host + Request.PathBase + Options.LoginPath + new QueryString(Options.ReturnUrlParameter, currentUri);
我的问题是什么规则管理两个路径属性中的最终结果:
OwinContext.Request.Path OwinContext.Request.PathBase
我已经尝试检查这些属性,因为请求通过下面管道中的不同处理程序,请求:
"https://localhost/Client/login" // Where Client is a virtual directory in IIS
结果:
在/ login的映射处理程序中,PathBase ="/ Client/Login".
但是当请求到达同一请求的路上时,我的QuillCodeFlowHandler中的ApplyResponseChallengeAsync方法得到了,PathBase ="/ Client"和Path ="/ Login".
因此,如果不知道如何填充这些值的"规则",然后更改,则很难使用它们构造URI.如果有人能解释,将不胜感激.
我的配置的摘录是:
app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = CookieAuthenticationDefaults.AuthenticationType, LoginPath = new PathString("/Login") }); app.UseQuillCodeFlowAuthentication(new QuillCodeFlowOptions()); app.Map("/login", map => { map.Run(async ctx => { if (ctx.Authentication.User == null || !ctx.Authentication.User.Identity.IsAuthenticated) { var authenticationProperties = new AuthenticationProperties(); [...] ctx.Authentication.Challenge(authenticationProperties, QuillCodeFlowDefaults.AuthenticationType);
该OWIN规范给出了一些解释和Microsoft.Owin.Host.HttpListener.GetPathAndQuery方法似乎是在路径变量的初始设置.