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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user