Mein Unternehmen benötigt die Integration aller Webanwendungen in OKTA. Diese App, über die ich geschrieben habe, wird auf dem Fargate-Cluster als Linux-Container gehostet (und verwendet Application Load Balancer + AWS-Zertifikat zur Verwendung von HTTPS). Der Container läuft auf HTTP und wird von ALB auf HTTPS umgeleitet.
Wenn ich auf den Hostnamen der Anwendung (https://exampleapp.companyname.com) zugreife, versucht er, mich zum folgenden Link umzuleiten:
Code: Select all
https://dev-1234567.okta.com/oauth2/default/v1/authorize?client_id=xyz&redirect_uri=http://exampleapp.companyname.com/signin-oidc&response_type=code&scope=openid profile email&code_challenge=xyz&code_challenge_method=S256&response_mode=form_post&nonce=xyz&x-client-ver=6.7.1.0
Warum versucht Okta, mich zu http:// umzuleiten, wenn ich über https:// auf die Seite zugreife?
Wenn ich versuche, die http://-Adresse zu Okta-Anmelde-URIs hinzuzufügen, Wenn ich versuche, auf die Seite zuzugreifen, tritt dieser Fehler auf tritt auf:
Code: Select all
The information you’re about to submit is not secure
Code: Select all
System.Exception: An error was encountered while handling the remote login.
---> System.Exception: OpenIdConnectAuthenticationHandler: message.State is null or empty.
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Dies sind meine „ConfigureServices“ in Startup.cs, die im Projekt verwendet werden:
Code: Select all
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.Cookie.SameSite = SameSiteMode.Lax;
})
.AddOpenIdConnect(options =>
{
options.NonceCookie.SecurePolicy = CookieSecurePolicy.Always;
options.CorrelationCookie.SecurePolicy = CookieSecurePolicy.Always;
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = oktaOrgUri;
options.RequireHttpsMetadata = true;
options.ClientId = oktaClientId;
options.ClientSecret = oktaClientSecret;
options.ResponseType = OpenIdConnectResponseType.Code;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("email");
options.SaveTokens = true;
options.TokenValidationParameters = new TokenValidationParameters
{
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(oktaClientSecret)),
NameClaimType = "name",
RoleClaimType = "groups",
ValidateIssuer = true
};
});
services.AddAuthorization();
}
Code: Select all
oktaOrgUri = https://dev-1234567.okta.com/oauth2/default
oktaClientId and oktaClientSecret filled with values from Okta
Code: Select all
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}