I am using an ASP.NET MVC application to connect to AD using owin middleware. This is the startup class:
try
{
IdentityModelEventSource.ShowPII = true;
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions{});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = Globals.Authority,
ClientId = Globals.ClientId,
RedirectUri = Globals.RedirectUri,
PostLogoutRedirectUri = Globals.RedirectUri,
Scope = Globals.BasicSignInScopes, // a basic set of permissions for user
// sign in & profile access
TokenValidationParameters =
new TokenValidationParameters
{
// In a real application you would use ValidateIssuer = true for
// additional checks and security.
NameClaimType = "email",
SaveSigninToken = false,
ValidateIssuer = false
},
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = OnSecurityTokenValidated,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
AuthenticationFailed = OnAuthenticationFailed
},
ResponseType = "id_token",
ProtocolValidator = new OpenIdConnectProtocolValidator()
{
RequireStateValidation = false,
RequireNonce = true},
CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
});
}
catch (Exception ex)
{
Log.Error("OwinMiddleWareIntialize Error", ex.Message);
}
We are using .NET Framework 4.8.
We are not getting redirected to the redirect URI which is mentioned in the AD, the screen is getting redirected to homepage.
I have checked some of the blogs they are asking to add the following code into CookieAuthentication
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
// ExpireTimeSpan = TimeSpan.FromMinutes(10),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieManager = new SameSiteCookieManager(new SystemWebCookieManager())
});
Any suggestion might help here thanks in advance
We are trying to authenticate AD login with Sitecore 10.2 docker using OwinMiddleware