Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 95ae2c74cf | |||
| 4576b5aa2b | |||
| 3847927ace | |||
| d38d1dd059 |
@@ -50,7 +50,8 @@ public static class Api
|
|||||||
{
|
{
|
||||||
var uriBuilder = new UriBuilder(context.ProtocolMessage.RedirectUri)
|
var uriBuilder = new UriBuilder(context.ProtocolMessage.RedirectUri)
|
||||||
{
|
{
|
||||||
Scheme = "https"
|
Scheme = "https",
|
||||||
|
Port = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
context.ProtocolMessage.RedirectUri = uriBuilder.Uri.ToString();
|
context.ProtocolMessage.RedirectUri = uriBuilder.Uri.ToString();
|
||||||
@@ -111,30 +112,14 @@ public static class Api
|
|||||||
|
|
||||||
app.MapGet("/logout", async (HttpContext context, IHttpClientFactory httpClientFactory, IOptions<AuthentikSettings> settings) =>
|
app.MapGet("/logout", async (HttpContext context, IHttpClientFactory httpClientFactory, IOptions<AuthentikSettings> settings) =>
|
||||||
{
|
{
|
||||||
var authOptions = settings.Value;
|
|
||||||
var accessToken = await context.GetTokenAsync("access_token");
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(accessToken))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var client = httpClientFactory.CreateClient();
|
|
||||||
|
|
||||||
var requestContent = new FormUrlEncodedContent(new Dictionary<string, string>(StringComparer.Ordinal)
|
|
||||||
{
|
|
||||||
{ "token", accessToken },
|
|
||||||
{ "client_id", authOptions.ClientId! },
|
|
||||||
{ "client_secret", authOptions.ClientSecret! },
|
|
||||||
});
|
|
||||||
|
|
||||||
await client.PostAsync(authOptions.RevokationEndpoint, requestContent, context.RequestAborted);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
|
|
||||||
return Results.Redirect($"{authOptions.Authority}end-session/");
|
string currentBaseUrl = $"https://{context.Request.Host}{context.Request.PathBase}/";
|
||||||
|
|
||||||
|
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
|
||||||
|
{
|
||||||
|
RedirectUri = currentBaseUrl
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
|||||||
Reference in New Issue
Block a user