6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 73b0b2a4
Changed files
.../android/app/src/main/AndroidManifest.xml | 22 +++++++ comwell_key_app/assets/msal/msal_config_dev.json | 19 ++++++ comwell_key_app/assets/msal/msal_config_prod.json | 19 ++++++ comwell_key_app/assets/msal/msal_config_stage.json | 19 ++++++ comwell_key_app/ios/Podfile | 4 +- .../ios/Runner.xcodeproj/project.pbxproj | 24 ++++---- comwell_key_app/ios/Runner/AppDelegate.swift | 9 ++- comwell_key_app/ios/Runner/Info.plist | 12 ++++ .../ios/Runner/RunnerRelease-Stage.entitlements | 10 +++ .../authentication/authentication_repository.dart | 8 ++- comwell_key_app/lib/login/cubit/login_cubit.dart | 71 ++++++++++++++-------- comwell_key_app/lib/login/login_page.dart | 4 +- comwell_key_app/lib/services/http_client.dart | 3 +- comwell_key_app/pubspec.yaml | 4 ++ 14 files changed, 183 insertions(+), 45 deletions(-)
Diff
diff --git a/comwell_key_app/android/app/src/main/AndroidManifest.xml b/comwell_key_app/android/app/src/main/AndroidManifest.xml
index 21cbd818..34feb75e 100644
--- a/comwell_key_app/android/app/src/main/AndroidManifest.xml
+++ b/comwell_key_app/android/app/src/main/AndroidManifest.xml
@@ -65,8 +65,30 @@
android:path="/api/auth/login/callback"
android:scheme="https" />
+
+ </intent-filter>
+ </activity>
+ <activity android:name="com.microsoft.identity.client.BrowserTabActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data
+ android:scheme="msauth"
+ android:host="com.comwell.phoenix.dev"
+ android:path="/PsrsGQrGkFzRWUJOtomYw29Pm1o=" />
+
+ <data
+ android:scheme="com.comwell.phoenix.dev"
+ android:host="auth"
+ android:path="" />
+ <data
+ android:scheme="msal"
+ android:host="com.comwell.phoenix.dev"
+ android:path="" />
</intent-filter>
</activity>
+
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
diff --git a/comwell_key_app/assets/msal/msal_config_dev.json b/comwell_key_app/assets/msal/msal_config_dev.json
new file mode 100644
index 00000000..51b60af5
--- /dev/null
+++ b/comwell_key_app/assets/msal/msal_config_dev.json
@@ -0,0 +1,19 @@
+{
+ "client_id" : "19a8eb05-01e0-4076-9db3-34bcfefd67d8",
+ "redirect_uri" : "msauth://com.comwell.phoenix.dev/PsrsGQrGkFzRWUJOtomYw29Pm1o=",
+ "shared_device_mode_supported": true,
+ "account_mode": "MULTIPLE",
+ "broker_redirect_uri_registered": false,
+ "authorization_user_agent": "BROWSER",
+ "authorities" : [
+ {
+ "type": "AAD",
+ "authority_url": "https://comwelliddev.ciamlogin.com/comwelliddev.onmicrosoft.com",
+ "audience": {
+ "type": "AzureADMyOrg",
+ "tenant_id": "8392ed03-7f96-414a-bc94-4f16dc0b9cf4"
+ },
+ "default": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/comwell_key_app/assets/msal/msal_config_prod.json b/comwell_key_app/assets/msal/msal_config_prod.json
new file mode 100644
index 00000000..9c773fa9
--- /dev/null
+++ b/comwell_key_app/assets/msal/msal_config_prod.json
@@ -0,0 +1,19 @@
+{
+ "client_id" : "19a8eb05-01e0-4076-9db3-34bcfefd67d8",
+ "redirect_uri" : "msauth://com.comwell.phoenix.stage/PsrsGQrGkFzRWUJOtomYw29Pm1o=",
+ "shared_device_mode_supported": true,
+ "account_mode": "MULTIPLE",
+ "broker_redirect_uri_registered": false,
+ "authorization_user_agent": "BROWSER",
+ "authorities" : [
+ {
+ "type": "AAD",
+ "authority_url": "https://comwellidstage.ciamlogin.com/comwellidstage.onmicrosoft.com",
+ "audience": {
+ "type": "AzureADMyOrg",
+ "tenant_id": "8392ed03-7f96-414a-bc94-4f16dc0b9cf4"
+ },
+ "default": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/comwell_key_app/assets/msal/msal_config_stage.json b/comwell_key_app/assets/msal/msal_config_stage.json
new file mode 100644
index 00000000..9c773fa9
--- /dev/null
+++ b/comwell_key_app/assets/msal/msal_config_stage.json
@@ -0,0 +1,19 @@
+{
+ "client_id" : "19a8eb05-01e0-4076-9db3-34bcfefd67d8",
+ "redirect_uri" : "msauth://com.comwell.phoenix.stage/PsrsGQrGkFzRWUJOtomYw29Pm1o=",
+ "shared_device_mode_supported": true,
+ "account_mode": "MULTIPLE",
+ "broker_redirect_uri_registered": false,
+ "authorization_user_agent": "BROWSER",
+ "authorities" : [
+ {
+ "type": "AAD",
+ "authority_url": "https://comwellidstage.ciamlogin.com/comwellidstage.onmicrosoft.com",
+ "audience": {
+ "type": "AzureADMyOrg",
+ "tenant_id": "8392ed03-7f96-414a-bc94-4f16dc0b9cf4"
+ },
+ "default": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/comwell_key_app/ios/Podfile b/comwell_key_app/ios/Podfile
index 1e170d1d..764f4a81 100644
--- a/comwell_key_app/ios/Podfile
+++ b/comwell_key_app/ios/Podfile
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
-platform :ios, '12.0'
+platform :ios, '14.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -45,7 +45,7 @@ post_install do |installer|
# Set minimum iOS deployment target to 12.0 for all pods
target.build_configurations.each do |config|
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
# Workaround to get SQLCipher to work on release config
diff --git a/comwell_key_app/ios/Runner.xcodeproj/project.pbxproj b/comwell_key_app/ios/Runner.xcodeproj/project.pbxproj
index 3e273e6d..35a46de7 100644
--- a/comwell_key_app/ios/Runner.xcodeproj/project.pbxproj
+++ b/comwell_key_app/ios/Runner.xcodeproj/project.pbxproj
@@ -30,6 +30,7 @@
5DF394EBD14723E019294B07 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
60E2CA932C11B89C00B7206F /* SeosMobileKeysSDK.xcframework */ = {isa = PBXFileReference; expectedSignature = "AppleDeveloperProgram:333BNLD22V:ASSAABLOY AB"; lastKnownFileType = wrapper.xcframework; name = SeosMobileKeysSDK.xcframework; path = ../../mobilekeys_sdk_plugin/XCFrameworks/SeosMobileKeysSDK.xcframework; sourceTree = "<group>"; };
7230779B2D54E062000859B0 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
+ 7240E4472E65C12C0057933D /* RunnerRelease-Stage.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "RunnerRelease-Stage.entitlements"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -128,6 +129,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
+ 7240E4472E65C12C0057933D /* RunnerRelease-Stage.entitlements */,
7230779B2D54E062000859B0 /* Runner.entitlements */,
FACB177B2A83B94A004F58BD /* RunnerRelease.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
@@ -470,7 +472,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -549,7 +551,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -635,7 +637,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -717,7 +719,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -791,7 +793,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
- CODE_SIGN_ENTITLEMENTS = Runner/RunnerRelease.entitlements;
+ CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-Stage.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
@@ -800,7 +802,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -883,7 +885,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -969,7 +971,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -1052,7 +1054,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -1188,7 +1190,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -1216,7 +1218,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Comwell Hotels";
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
diff --git a/comwell_key_app/ios/Runner/AppDelegate.swift b/comwell_key_app/ios/Runner/AppDelegate.swift
index b6363034..26eda07d 100644
--- a/comwell_key_app/ios/Runner/AppDelegate.swift
+++ b/comwell_key_app/ios/Runner/AppDelegate.swift
@@ -1,5 +1,6 @@
import UIKit
import Flutter
+import MSAL
@main
@objc class AppDelegate: FlutterAppDelegate {
@@ -10,4 +11,10 @@ import Flutter
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
-}
+
+
+ override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
+ return MSALPublicClientApplication.handleMSALResponse(url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String)
+ }
+
+}
\ No newline at end of file
diff --git a/comwell_key_app/ios/Runner/Info.plist b/comwell_key_app/ios/Runner/Info.plist
index a08bdc75..dcafef7e 100644
--- a/comwell_key_app/ios/Runner/Info.plist
+++ b/comwell_key_app/ios/Runner/Info.plist
@@ -29,6 +29,16 @@
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>MSAL</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>msauth.com.comwell.phoenix.dev</string>
+ <string>msauth.com.comwell.phoenix.stage</string>
+ <string>msauth.com.comwell.phoenix</string>
+ </array>
+ </dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
@@ -46,6 +56,8 @@
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
+ <string>msauthv2</string>
+ <string>msauthv3</string>
<string>sms</string>
<string>tel</string>
</array>
diff --git a/comwell_key_app/ios/Runner/RunnerRelease-Stage.entitlements b/comwell_key_app/ios/Runner/RunnerRelease-Stage.entitlements
new file mode 100644
index 00000000..5d6e38ad
--- /dev/null
+++ b/comwell_key_app/ios/Runner/RunnerRelease-Stage.entitlements
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>keychain-access-groups</key>
+ <array>
+ <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
+ </array>
+</dict>
+</plist>
diff --git a/comwell_key_app/lib/authentication/authentication_repository.dart b/comwell_key_app/lib/authentication/authentication_repository.dart
index 07dcec15..df66444e 100644
--- a/comwell_key_app/lib/authentication/authentication_repository.dart
+++ b/comwell_key_app/lib/authentication/authentication_repository.dart
@@ -60,7 +60,11 @@ class AuthenticationRepository {
value: 'true',
);
// Ensure DB is re-instantiated after login
- registerDatabase();
+ try {
+ registerDatabase();
+ } catch (e) {
+ // no op
+ }
}
Future<void> logOut({bool forced = false}) async {
@@ -85,7 +89,7 @@ class AuthenticationRepository {
Future<bool> doesTokenExist() async {
final refreshToken = await secureStorage.read(constants.refreshToken);
final accessToken = await secureStorage.read(constants.accessToken);
- return refreshToken != null && accessToken != null;
+ return accessToken != null;
}
Future<void> loginWithCode(String code) async {
diff --git a/comwell_key_app/lib/login/cubit/login_cubit.dart b/comwell_key_app/lib/login/cubit/login_cubit.dart
index 2a81d16b..c9062420 100644
--- a/comwell_key_app/lib/login/cubit/login_cubit.dart
+++ b/comwell_key_app/lib/login/cubit/login_cubit.dart
@@ -1,40 +1,59 @@
import 'package:bloc/bloc.dart';
-import 'package:comwell_key_app/login/auth.dart';
+import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:equatable/equatable.dart';
+import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
-import 'package:uri/uri.dart';
+import 'package:msal_auth/msal_auth.dart';
part 'login_state.dart';
class LoginCubit extends Cubit<LoginState> {
- LoginCubit({required this.forced}) : super(LoginState());
+ LoginCubit({required this.forced, required this.authRepository})
+ : super(LoginState());
final bool forced;
+ final AuthenticationRepository authRepository;
- Uri constructUrl(Auth authType) {
- final tenantName = dotenv.env["ENTRA_ID_TENANT_NAME"]!;
+ Future<void> login() async {
+ await _openAuth(Prompt.login);
+ }
+
+ Future<void> createAccount() async {
+ await _openAuth(Prompt.create);
+ }
+
+ Future<void> _openAuth(Prompt promt) async {
final clientId = dotenv.env["ENTRA_ID_CLIENT_ID"]!;
final redirect = dotenv
.env["ENTRA_ID_REDIRECT_URL"]!; // should probably be an env variable
- const scopes = "openid"; //"email+User.Read+profile+openid+offline_access";
- const responseType = "id_token";
- const prompt = "login";
- final state = dotenv.env["ENTRA_ID_STATE"]!;
- const ssoReload = true;
- final uri = Uri.parse(
- "https://$tenantName.ciamlogin.com/$tenantName.onmicrosoft.com/oauth2/v2.0/authorize",
- );
- final queryParams = {
- "redirect_uri": redirect,
- "client_id": clientId,
- "scope": scopes,
- "prompt": prompt,
- "response_type": responseType,
- "state": state,
- "nonce": "Ou_mR9zKKK",
- "sso_reload": "$ssoReload"
- };
- UriBuilder uriBuilder = UriBuilder.fromUri(uri);
- uriBuilder.queryParameters.addAll(queryParams);
- return uriBuilder.build();
+
+ final String configFilePath;
+ switch (appFlavor) {
+ case "Develop":
+ configFilePath = 'assets/msal/msal_config_dev.json';
+ case "Stage":
+ configFilePath = 'assets/msal/msal_config_stage.json';
+ case "Prod":
+ configFilePath = 'assets/msal/msal_config_prod.json';
+ default:
+ throw Exception("Missing config file for flavor $appFlavor");
+ }
+
+ try {
+ final msalAuth = await MultipleAccountPca.create(
+ clientId: clientId,
+ androidConfig: AndroidConfig(
+ configFilePath: configFilePath,
+ redirectUri: redirect,
+ ),
+ appleConfig: AppleConfig(
+ authorityType: AuthorityType.aad,
+ broker: Broker.webView,
+ ));
+ final token = await msalAuth
+ .acquireToken(scopes: ["api://19a8eb05-01e0-4076-9db3-34bcfefd67d8/Apim.Access"], prompt: promt);
+ await authRepository.loginWithCode(token.accessToken);
+ } catch (e) {
+ print("qqq e=$e");
+ }
}
}
diff --git a/comwell_key_app/lib/login/login_page.dart b/comwell_key_app/lib/login/login_page.dart
index 2aa87451..77c2342b 100644
--- a/comwell_key_app/lib/login/login_page.dart
+++ b/comwell_key_app/lib/login/login_page.dart
@@ -41,12 +41,12 @@ class LoginPage extends StatelessWidget {
const SizedBox(height: 32),
LoginButton(
onPressed: () {
- launchUrl(cubit.constructUrl(Auth.login));
+ cubit.login();
},
),
const SizedBox(height: 10),
CreateUserButton(onPressed: () {
- launchUrl(cubit.constructUrl(Auth.createUser));
+ cubit.createAccount();
}),
const SizedBox(height: 20),
],
diff --git a/comwell_key_app/lib/services/http_client.dart b/comwell_key_app/lib/services/http_client.dart
index dc2587db..9482f380 100644
--- a/comwell_key_app/lib/services/http_client.dart
+++ b/comwell_key_app/lib/services/http_client.dart
@@ -2,6 +2,7 @@ import 'package:comwell_key_app/services/interceptors/response_handle_intercepto
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
+import 'package:pretty_dio_logger/pretty_dio_logger.dart';
class HttpClient {
@@ -23,7 +24,7 @@ class HttpClient {
),
);
dio.interceptors.add(ResponseHandleInterceptor(dio));
- if(kDebugMode) dio.interceptors.add(LogInterceptor());
+ if(kDebugMode) dio.interceptors.add(PrettyDioLogger(requestHeader: true));
return dio;
}
diff --git a/comwell_key_app/pubspec.yaml b/comwell_key_app/pubspec.yaml
index d881b2b7..09c2b890 100644
--- a/comwell_key_app/pubspec.yaml
+++ b/comwell_key_app/pubspec.yaml
@@ -59,6 +59,9 @@ dependencies:
shimmer: ^3.0.0
in_app_update: ^4.2.3
uri: ^1.0.0
+ pretty_dio_logger: ^1.4.0
+ msal_auth: ^3.3.0
+
dependency_overrides:
#Remove override when slider button updates
@@ -86,6 +89,7 @@ flutter:
uses-material-design: true
assets:
+ - assets/msal/
- assets/animations/
- assets/translations/
- assets/images/