我试图通过OWIN中间件在Amazon Cognito中使用已配置的SAML Provider进行身份验证的MVC 5应用程序。
在我的启动课程中,我有:
app.Use(typeof(AuthenticationMiddleware));
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = MyCustomValidateIdentity
},
SlidingExpiration = true,
ExpireTimeSpan = TimeSpan.FromMinutes(timespan)
});
var config = ConfigHelper.CognitoConfigSection;
var signingCert = new X509Certificate2(Encoding.ASCII.GetBytes(config.cert));
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "Cognito",
AuthenticationMode = AuthenticationMode.Passive,
Authority = $"https://cognito-idp.{config.Region}.amazonaws.com/{config.UserPoolId}",
ResponseType = "code",
ClientId = config.UserpoolClientId,
ClientSecret = config.UserpoolClientSecret,
Scope = String.Join(" ", "openid", "profile", "email"),
MetadataAddress = $"https://cognito-idp.{config.Region}.amazonaws.com/{config.UserPoolId}/.well-known/openid-configuration",
RedirectUri = "http://localhost:12345",
TokenValidationParameters = new TokenValidationParameters …Run Code Online (Sandbox Code Playgroud)