TF-607 Implement logoutOidc action when user click signOut
This commit is contained in:
@@ -23,5 +23,5 @@ abstract class AuthenticationOIDCDataSource {
|
||||
List<String> scopes,
|
||||
String refreshToken);
|
||||
|
||||
Future<void> logout(TokenId tokenId, OIDCConfiguration config);
|
||||
Future<bool> logout(TokenId tokenId, OIDCConfiguration config);
|
||||
}
|
||||
@@ -71,7 +71,11 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> logout(TokenId tokenId, OIDCConfiguration config) {
|
||||
throw UnimplementedError();
|
||||
Future<bool> logout(TokenId tokenId, OIDCConfiguration config) {
|
||||
return Future.sync(() async {
|
||||
return await _oidcHttpClient.logoutOidc(tokenId, config);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,8 @@ class AuthorizationInterceptors extends InterceptorsWrapper {
|
||||
|
||||
OIDCConfiguration? get oidcConfig => _configOIDC;
|
||||
|
||||
AuthenticationType get authenticationType => _authenticationType;
|
||||
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
switch(_authenticationType) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:flutter_appauth/flutter_appauth.dart';
|
||||
import 'package:model/oidc/oidc_configuration.dart';
|
||||
import 'package:model/oidc/request/oidc_request.dart';
|
||||
import 'package:model/oidc/response/oidc_response.dart';
|
||||
import 'package:model/oidc/token_id.dart';
|
||||
import 'package:model/oidc/token_oidc.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/authentication_token_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/service_path_extension.dart';
|
||||
@@ -98,4 +99,14 @@ class OIDCHttpClient {
|
||||
throw NotFoundAccessTokenException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> logoutOidc(TokenId tokenId, OIDCConfiguration config) async {
|
||||
final endSession = await _appAuth.endSession(EndSessionRequest(
|
||||
idTokenHint: tokenId.uuid,
|
||||
postLogoutRedirectUrl: config.redirectUrl,
|
||||
discoveryUrl: config.discoveryUrl
|
||||
));
|
||||
log('OIDCHttpClient::logoutOidc(): ${endSession?.state}');
|
||||
return endSession?.state?.isNotEmpty == true;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class AuthenticationOIDCRepositoryImpl extends AuthenticationOIDCRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> logout(TokenId tokenId, OIDCConfiguration config) {
|
||||
throw UnimplementedError();
|
||||
Future<bool> logout(TokenId tokenId, OIDCConfiguration config) {
|
||||
return _oidcDataSource.logout(tokenId, config);
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,5 @@ abstract class AuthenticationOIDCRepository {
|
||||
List<String> scopes,
|
||||
String refreshToken);
|
||||
|
||||
Future<void> logout(TokenId tokenId, OIDCConfiguration config);
|
||||
Future<bool> logout(TokenId tokenId, OIDCConfiguration config);
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class GetAuthenticatedAccountInteractor {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final account = await _accountRepository.getCurrentAccount();
|
||||
log('GetAuthenticatedAccountInteractor::execute(): account: $account');
|
||||
yield Right(GetAuthenticatedAccountSuccess(account));
|
||||
if (account.authenticationType == AuthenticationType.oidc) {
|
||||
yield* _getStoredTokenOidcInteractor.execute(account.id);
|
||||
|
||||
@@ -18,6 +18,7 @@ class GetStoredTokenOidcInteractor {
|
||||
|
||||
Stream<Either<Failure, Success>> execute(String tokenIdHash) async* {
|
||||
try {
|
||||
log('GetStoredTokenOidcInteractor::execute(): tokenIdHash: $tokenIdHash');
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final futureValue = await Future.wait([
|
||||
_credentialRepository.getBaseUrl(),
|
||||
|
||||
Reference in New Issue
Block a user