问题描述
我有一个 ASP.NET 框架应用程序,我正在为其启用 OneLogin OIDC 身份验证。我已经在启动时完成了必要的配置。应用程序被重定向到一次登录以进行身份验证。然后将回复 POST 回返回 URL。我已将 .aspx 页面作为返回 URL。 登录 OneLogin 后,当我尝试检索 GetExternalLoginInfo 时,它始终返回 null。我正在使用以下代码。
var loginInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo();
这是我用于 OIDC 配置的代码
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.CreatePerOwinContext(UserDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Logon.aspx"),Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = context => SecurityStampValidator.OnValidateIdentity<ApplicationUserManager,ApplicationUser,string>(
validateInterval: TimeSpan.FromMinutes(30),regenerateIdentityCallback: (manager,user) => user.GenerateUserIdentityAsync(manager,context.Identity),getUserIdCallback: (ci) => ci.GetUserId()).Invoke(context)
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie,TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "OneLogin",ClientId = clientId,ClientSecret = appKey,Authority = ConfigurationManager.AppSettings["ida:OneLoginAuthority"],//ResponseType = OpenIdConnectResponseTypes.CodeIdToken,ResponseType = "Code",PostLogoutRedirectUri = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"],RedirectUri = redirectUri,TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
{
ValidateIssuer = false,ValidIssuers = PaperSave.PaaSAuthentication.Utility.Utility.GetValidIssuers(),},Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = (context) =>
{
return System.Threading.Tasks.Task.FromResult(0);
},//
AuthorizationCodeReceived = (context) =>
{
return System.Threading.Tasks.Task.FromResult(0);
},RedirectToIdentityProvider = (context) =>
{
if (context.OwinContext.Authentication.AuthenticationResponseChallenge != null)
{
}
return System.Threading.Tasks.Task.FromResult(0);
},AuthenticationFailed = (context) =>
{
return System.Threading.Tasks.Task.FromResult(0);
}
}
}
);
我已按照 this url 在 onelogin 端配置应用程序。
感谢任何指点。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)