Hello Okta Community,
I’m currently integrating Okta OpenID Connect (OIDC) authentication in an ASP.NET Core application. I’ve configured the Okta app settings and provided the necessary redirect URIs, but I’m running into an issue where the redirect_uri
in the authentication request defaults to HTTP instead of HTTPS.
Application Configuration in Okta:
- Sign-In Redirect URI:
https://web-app.wittyhill-09cfa093.eastus.azurecontainerapps.io/authorization-code/callback
- Sign-Out Redirect URI:
https://web-app.wittyhill-09cfa093.eastus.azurecontainerapps.io/signout-callback
- Allow Wildcard: Disabled
- Login Initiated By: App Only
Code Configuration (ASP.NET Core):
csharp
Copy code
oidcOptions.CallbackPath = new PathString("/authorization-code/callback");
oidcOptions.SignedOutCallbackPath = new PathString("/signout-callback");
oidcOptions.ClientId = clientId;
oidcOptions.ClientSecret = clientSecret;
oidcOptions.Authority = issuer;
oidcOptions.ResponseType = "code";
oidcOptions.SaveTokens = true;
oidcOptions.Scope.Add("openid");
oidcOptions.Scope.Add("profile");
oidcOptions.Scope.Add("email");
oidcOptions.Scope.Add("roles");
oidcOptions.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = ClaimTypes.Role,
ValidateIssuer = true,
};
I’ve also enforced HTTPS in the application with the following:
csharp
Copy code
services.Configure<CookiePolicyOptions>(options =>
{
options.Secure = CookieSecurePolicy.Always;
});
Issue:
When I initiate the login flow, Okta redirects back to my app, but the redirect_uri
in the authentication request URL is showing up as http://web-app.wittyhill-09cfa093.eastus.azurecontainerapps.io/authorization-code/callback
instead of https
.
Troubleshooting Steps Taken:
- Verified that HTTPS is enforced across the application.
- Double-checked that the correct Sign-In Redirect URI (with HTTPS) is set in the Okta application settings.
- Tried explicitly setting
oidcOptions.CallbackPath
and also consideredSignedOutCallbackPath
. - Attempted to force HTTPS in ASP.NET Core configuration, but the redirect URI still defaults to HTTP.
Questions:
- Is there an additional setting in Okta or ASP.NET Core to ensure the redirect URI protocol is HTTPS?
- Has anyone faced this issue where the redirect URI defaults to HTTP despite HTTPS being enforced?
- Are there any other configurations in Okta or ASP.NET Core that I might be missing?
Thanks for any guidance on this issue! I’d appreciate any insights from the community.