mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Authentication - Sign out in the browser when logging out
This commit is contained in:
parent
e5a5f10286
commit
36bff3c5f3
@ -12,14 +12,16 @@ internal class AuthenticationToken
|
||||
if (tokenResponse.RefreshToken == null)
|
||||
throw new ArtemisWebClientException("Token response contains no refresh token");
|
||||
|
||||
IdentityToken = tokenResponse.IdentityToken;
|
||||
AccessToken = tokenResponse.AccessToken;
|
||||
RefreshToken = tokenResponse.RefreshToken;
|
||||
ExpiresAt = DateTimeOffset.UtcNow.AddSeconds(tokenResponse.ExpiresIn);
|
||||
}
|
||||
|
||||
|
||||
public DateTimeOffset ExpiresAt { get; private set; }
|
||||
public bool Expired => DateTimeOffset.UtcNow.AddSeconds(5) >= ExpiresAt;
|
||||
|
||||
public string? IdentityToken { get; private set; }
|
||||
public string AccessToken { get; private set; }
|
||||
public string RefreshToken { get; private set; }
|
||||
}
|
||||
@ -258,12 +258,21 @@ internal class AuthenticationService : CorePropertyChanged, IAuthenticationServi
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Logout()
|
||||
public async Task Logout()
|
||||
{
|
||||
DiscoveryDocumentResponse disco = await GetDiscovery();
|
||||
|
||||
// Open the web browser for the user to log out
|
||||
if (disco.EndSessionEndpoint != null)
|
||||
{
|
||||
RequestUrl authRequestUrl = new(disco.EndSessionEndpoint);
|
||||
string url = authRequestUrl.CreateEndSessionUrl(_token?.IdentityToken);
|
||||
Utilities.OpenUrl(url);
|
||||
}
|
||||
|
||||
_token = null;
|
||||
_claims.Clear();
|
||||
SetStoredRefreshToken(null);
|
||||
|
||||
_isLoggedInSubject.OnNext(false);
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,6 @@ public interface IAuthenticationService : IProtectedArtemisService
|
||||
Task<string?> GetBearer();
|
||||
Task<bool> AutoLogin(bool force = false);
|
||||
Task Login(CancellationToken cancellationToken);
|
||||
void Logout();
|
||||
Task Logout();
|
||||
bool GetIsEmailVerified();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user