Support configuration for OIDC scopes
(cherry picked from commit 8dc7d6d025deaf0e36729dbcade3fd9bcaf91b8c)
This commit is contained in:
committed by
Dat H. Pham
parent
0c6d0eded0
commit
b10cc840ce
@@ -1,6 +1,7 @@
|
||||
SERVER_URL=http://localhost/
|
||||
DOMAIN_REDIRECT_URL=http://localhost:3000
|
||||
WEB_OIDC_CLIENT_ID=teammail-web
|
||||
OIDC_SCOPES=openid,profile,email
|
||||
APP_GRID_AVAILABLE=supported
|
||||
FCM_AVAILABLE=supported
|
||||
IOS_FCM=supported
|
||||
@@ -3,6 +3,7 @@ import 'package:model/oidc/oidc_configuration.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
|
||||
class OidcConfigurationCacheManager {
|
||||
final SharedPreferences _sharedPreferences;
|
||||
@@ -17,7 +18,7 @@ class OidcConfigurationCacheManager {
|
||||
return OIDCConfiguration(
|
||||
authority: authority,
|
||||
clientId: OIDCConstant.clientId,
|
||||
scopes: OIDCConstant.oidcScope);
|
||||
scopes: AppConfig.oidcScopes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
|
||||
class OIDCConstant {
|
||||
static String get mobileOidcClientId => 'teammail-mobile';
|
||||
static List<String> get oidcScope => ['openid', 'offline_access'];
|
||||
static List<String> get oidcScope => ['openid', 'email'];
|
||||
static const keyAuthorityOidc = 'KEY_AUTHORITY_OIDC';
|
||||
static const authResponseKey = "auth_info";
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@ import 'package:core/data/network/dio_client.dart';
|
||||
import 'package:core/utils/app_logger.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/response/oidc_discovery_response.dart';
|
||||
import 'package:model/oidc/response/oidc_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/service_path_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/endpoint.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
|
||||
class OIDCHttpClient {
|
||||
|
||||
@@ -45,7 +46,7 @@ class OIDCHttpClient {
|
||||
return OIDCConfiguration(
|
||||
authority: oidcResponse.links[0].href.toString(),
|
||||
clientId: OIDCConstant.clientId,
|
||||
scopes: OIDCConstant.oidcScope
|
||||
scopes: AppConfig.oidcScopes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart';
|
||||
|
||||
class AppConfig {
|
||||
static String get baseUrl => dotenv.get('SERVER_URL', fallback: '');
|
||||
@@ -28,4 +29,18 @@ class AppConfig {
|
||||
static String appFCMConfigurationPath = "configurations/env.fcm";
|
||||
|
||||
static String get fcmVapidPublicKeyWeb => dotenv.get('FIREBASE_WEB_VAPID_PUBLIC_KEY', fallback: '');
|
||||
|
||||
static List<String> get oidcScopes {
|
||||
try {
|
||||
final envScopes = dotenv.get('OIDC_SCOPES', fallback: '');
|
||||
|
||||
if (envScopes.isNotEmpty) {
|
||||
return envScopes.split(',');
|
||||
}
|
||||
|
||||
return OIDCConstant.oidcScope;
|
||||
} catch (e) {
|
||||
return OIDCConstant.oidcScope;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user