public class TokenAuthorizeFilter : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext context)
{
if (!context.HttpContext.User.Identity.IsAuthenticated)
{
#if !DEBUG
HttpContext.Current.GetOwinContext().Authentication.Challenge(new AuthenticationProperties
{
RedirectUri= context.HttpContext.Request.Url.ToString().Replace("http", "https")
});
#endif
// 401 who are you? go login and then try again
context.Result = new HttpUnauthorizedResult();
}
//如果 session 不存在,清除 openid
// context.RequestContext.HttpContext.GetOwinContext().Authentication.SignOut();
// context.Result = new RedirectResult("/home?returnUrl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri));
}
}
OpenIdConnect 认证启用 HTTPS 回调 RedirectUri 不生效问(6)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/7b91b1bdf1bdd009dcd8ec23be92c1d1.html