TF-624 Implement get authentication info

This commit is contained in:
dab246
2022-06-07 19:59:01 +07:00
committed by Dat H. Pham
parent 5c66d3016f
commit abc7e3da9d
12 changed files with 106 additions and 0 deletions
@@ -12,6 +12,8 @@ abstract class AuthenticationClientBase {
String discoveryUrl,
List<String> scopes);
Future<String?> getAuthenticationInfo();
Future<TokenOIDC> getTokenOIDC(
String clientId,
String redirectUrl,
@@ -81,6 +81,11 @@ class AuthenticationClientMobile implements AuthenticationClientBase {
String discoveryUrl, List<String> scopes) {
return Future.value(null);
}
@override
Future<String?> getAuthenticationInfo() {
return Future.value(null);
}
}
AuthenticationClientBase getAuthenticationClientImplementation() =>
@@ -1,5 +1,8 @@
import 'package:core/utils/app_logger.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart';
import 'package:universal_html/html.dart' as html;
import 'package:tmail_ui_user/features/login/data/network/authentication_client/authentication_client_base.dart';
import 'package:flutter_appauth_platform_interface/flutter_appauth_platform_interface.dart';
import 'package:model/oidc/oidc_configuration.dart';
@@ -41,6 +44,13 @@ class AuthenticationClientWeb implements AuthenticationClientBase {
discoveryUrl: discoveryUrl,
scopes: scopes));
}
@override
Future<String?> getAuthenticationInfo() async {
final authUrl = html.window.sessionStorage[OIDCConstant.authResponseKey];
log('AuthenticationClientWeb::getAuthenticationInfo(): authUrl: $authUrl');
return authUrl;
}
}
AuthenticationClientBase getAuthenticationClientImplementation() =>
@@ -5,6 +5,7 @@ class OIDCConstant {
static String get webOidcClientId => 'teammail-web';
static List<String> get oidcScope => ['openid', 'offline_access'];
static const keyAuthorityOidc = 'KEY_AUTHORITY_OIDC';
static const authResponseKey = "auth_info";
static String get clientId => BuildUtils.isWeb ? webOidcClientId : mobileOidcClientId;
}