Merge pull request 'Fixed the redirect URI on logout so its passed by the caller' (#118) from logout-fix into master
Reviewed-on: #118
This commit was merged in pull request #118.
This commit is contained in:
@@ -18,7 +18,7 @@ public static class Api
|
|||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddSecurityApiSdk(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddSecurityApiSdk(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var configSection = configuration.GetSection(nameof(LiteCharmsClientSettings));
|
var configSection = configuration.GetSection(nameof(LiteCharmsClientSettings));
|
||||||
@@ -143,13 +143,19 @@ public static class Api
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapGet("/logout", async (HttpContext context) =>
|
app.MapGet("/logout", async (HttpContext context, string? redirectUri = null) =>
|
||||||
{
|
{
|
||||||
var idToken = await context.GetTokenAsync("id_token");
|
var idToken = await context.GetTokenAsync("id_token");
|
||||||
|
|
||||||
var authProperties = new AuthenticationProperties { RedirectUri = "/", };
|
if (string.IsNullOrWhiteSpace(redirectUri))
|
||||||
|
{
|
||||||
|
var host = context.Request.Host.ToUriComponent();
|
||||||
|
redirectUri = $"https://{host}/";
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(idToken))
|
var authProperties = new AuthenticationProperties { RedirectUri = redirectUri, };
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(idToken))
|
||||||
authProperties.Parameters.Add("id_token_hint", idToken);
|
authProperties.Parameters.Add("id_token_hint", idToken);
|
||||||
|
|
||||||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, authProperties);
|
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, authProperties);
|
||||||
|
|||||||
Reference in New Issue
Block a user