Skip to content
This repository was archived by the owner on Feb 11, 2023. It is now read-only.

Commit fc2b140

Browse files
Chase R. Crawford (Tek)Chase R. Crawford (Tek)
authored andcommitted
Added Fixes for Web and ios
1 parent 23918e0 commit fc2b140

File tree

8 files changed

+69
-41
lines changed

8 files changed

+69
-41
lines changed

src/msal-capacitor-plugin-demo/ios/App/App.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@
349349
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
350350
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
351351
CODE_SIGN_STYLE = Automatic;
352-
DEVELOPMENT_TEAM = NGDMY4TLA6;
352+
DEVELOPMENT_TEAM = "";
353353
INFOPLIST_FILE = App/Info.plist;
354-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
354+
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
355355
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
356356
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
357-
PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter;
357+
PRODUCT_BUNDLE_IDENTIFIER = some.bundle.id;
358358
PRODUCT_NAME = "$(TARGET_NAME)";
359359
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG USE_PUSH";
360360
SWIFT_VERSION = 5.0;
@@ -369,11 +369,11 @@
369369
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
370370
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
371371
CODE_SIGN_STYLE = Automatic;
372-
DEVELOPMENT_TEAM = NGDMY4TLA6;
372+
DEVELOPMENT_TEAM = "";
373373
INFOPLIST_FILE = App/Info.plist;
374-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
374+
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
375375
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
376-
PRODUCT_BUNDLE_IDENTIFIER = io.ionic.starter;
376+
PRODUCT_BUNDLE_IDENTIFIER = some.bundle.id;
377377
PRODUCT_NAME = "$(TARGET_NAME)";
378378
SWIFT_ACTIVE_COMPILATION_CONDITIONS = USE_PUSH;
379379
SWIFT_VERSION = 5.0;

src/msal-capacitor-plugin-demo/ios/App/App/App.entitlements

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
<dict>
55
<key>keychain-access-groups</key>
66
<array>
7-
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
8-
<string>$(AppIdentifierPrefix)com.microsoft.identity.universalstorage</string>
9-
<string>$(AppIdentifierPrefix)sessionStorage</string>
7+
<string>$(AppIdentifierPrefix)com.company.cache</string>
108
</array>
119
</dict>
1210
</plist>

src/msal-capacitor-plugin-demo/ios/App/App/Info.plist

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>LSApplicationQueriesSchemes</key>
6-
<array>
7-
<string>msauthv2</string>
8-
<string>msauthv3</string>
9-
</array>
10-
<key>NSFaceIDUsageDescription</key>
11-
<string>For an easier and faster log in.</string>
125
<key>CFBundleDevelopmentRegion</key>
136
<string>en</string>
147
<key>CFBundleDisplayName</key>
@@ -33,12 +26,17 @@
3326
<key>CFBundleURLSchemes</key>
3427
<array>
3528
<string>capacitor</string>
36-
<string>msauth.assimalign.MSALiOS</string>
29+
<string></string>
3730
</array>
3831
</dict>
3932
</array>
4033
<key>CFBundleVersion</key>
4134
<string>1</string>
35+
<key>LSApplicationQueriesSchemes</key>
36+
<array>
37+
<string>msauthv2</string>
38+
<string>msauthv3</string>
39+
</array>
4240
<key>LSRequiresIPhoneOS</key>
4341
<true/>
4442
<key>NSAppTransportSecurity</key>
@@ -48,6 +46,8 @@
4846
</dict>
4947
<key>NSCameraUsageDescription</key>
5048
<string>To Take Photos and Video</string>
49+
<key>NSFaceIDUsageDescription</key>
50+
<string>For an easier and faster log in.</string>
5151
<key>NSLocationAlwaysUsageDescription</key>
5252
<string>Always allow Geolocation?</string>
5353
<key>NSLocationWhenInUseUsageDescription</key>

src/msal-capacitor-plugin-demo/ios/App/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def capacitor_pods
1010
# Automatic Capacitor Pod dependencies, do not delete
1111
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
1212
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
13-
pod 'AssimalignMsalCapacitorPlugin', :path => '..\..\..\msal-capacitor-plugin'
13+
pod 'AssimalignMsalCapacitorPlugin', :path => '../../../msal-capacitor-plugin'
1414
# Do not delete
1515
end
1616

src/msal-capacitor-plugin-demo/src/context/auth/AuthContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export const useAuthentication = (): IAuthContext => {
2121
}, []);
2222

2323
const initializeOptions = async() => {
24-
let uri = isPlatform('capacitor') ? 'msauth.{iOS MAC redirect Url}://auth' : 'http://localhost:3000';
24+
let uri = isPlatform('capacitor') ? 'msauth.{bundle Id}://auth' : 'http://localhost:3000';
2525
console.log(uri);
2626
(await MsalCap.setOptions({
27-
clientId: 'Client ID',
28-
authority: `https://login.microsoftonline.com/{Tenant ID}`,
27+
clientId: 'Client Id',
28+
authority: `https://login.microsoftonline.com/{Tenant Id}`,
2929
redirectUri: uri,
3030
scopes: [
3131
'user.read'

src/msal-capacitor-plugin/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ Below are examples are of how to implement an authentication provider that can b
3030
- Step 4 : `npm i @assimalign/msal-capacitor-plugin`
3131
- Step 5 : `ionic cap sync` Downlaoad Package
3232

33+
34+
### Ios Specific Setup: Add keys to info.plist File
35+
```xml
36+
<key>LSApplicationQueriesSchemes</key>
37+
<array>
38+
<string>msauthv2</string>
39+
<string>msauthv3</string>
40+
</array>
41+
<key>CFBundleURLTypes</key>
42+
<array>
43+
<dict>
44+
<key>CFBundleURLName</key>
45+
<string>com.getcapacitor.capacitor</string>
46+
<key>CFBundleURLSchemes</key>
47+
<array>
48+
<string>capacitor</string>
49+
<string><!--The Key Sharing Groups which will be added to XCode--></string>
50+
</array>
51+
</dict>
52+
</array>
53+
<!-- If use Biometric Auth-->
54+
<key>NSFaceIDUsageDescription</key>
55+
<string>For an easier and faster log in.</string>
56+
```
3357
---
3458

3559
## React App Instruction (Typescript)
@@ -61,8 +85,7 @@ Using `useContext` hook we will implement an auth provider that will wrap our ap
6185
import { IAuthContext } from './types';
6286
import { Plugins } from '@capacitor/core';
6387
import { isPlatform } from '@ionic/react';
64-
import { AvailableResult, BiometryType } from 'capacitor-native-biometric';
65-
import '@eastdil/msal-capacitor-plugin';
88+
import '@assimalign/msal-capacitor-plugin';
6689

6790
const AuthContext = createContext<IAuthContext>({
6891
isAuthenticated: () => { },

src/msal-capacitor-plugin/ios/Plugin/Plugin.swift

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,25 @@ public class MsalPlugin: CAPPlugin {
4545
} else {
4646
self.msalUseBiometrics = isoOptions["enableBiometrics"] as! Bool;
4747
}
48+
49+
var tokenCache = ""
4850

49-
var tokenCache = ""
51+
#if os(iOS)
52+
if isoOptions["keyShareLocation"] == nil {
53+
tokenCache = "com.microsoft.adalcache"
54+
} else {
55+
tokenCache = isoOptions["keyShareLocation"] as! String
56+
}
57+
#else
58+
if isoOptions["keyShareLocation"] == nil {
59+
tokenCache = "com.microsoft.identity.universalstorage"
60+
} else {
61+
tokenCache = isoOptions["keyShareLocation"] as! String
62+
}
63+
#endif
64+
clientConfiguration.cacheConfig.keychainSharingGroup = tokenCache
5065

51-
#if os(iOS)
52-
if isoOptions["keyShareLocation"] == nil {
53-
tokenCache = "com.microsoft.adalcache"
54-
} else {
55-
tokenCache = isoOptions["keyShareLocation"] as! String
56-
}
57-
#else
58-
if isoOptions["keyShareLocation"] == nil {
59-
tokenCache = "com.microsoft.identity.universalstorage"
60-
} else {
61-
tokenCache = isoOptions["keyShareLocation"] as! String
62-
}
63-
#endif
64-
clientConfiguration.cacheConfig.keychainSharingGroup = tokenCache
66+
6567
} else {
6668
self.msalUseBiometrics = false
6769
}
@@ -209,7 +211,7 @@ public class MsalPlugin: CAPPlugin {
209211
if success {
210212
DispatchQueue.main.async {
211213
self.setCurrentAccount {(account) in
212-
guard let currentAccount = self.msalAccount else {
214+
guard let currentAccount = account else {
213215
self.loginInteractive(call)
214216
return
215217
}
@@ -255,6 +257,10 @@ public class MsalPlugin: CAPPlugin {
255257

256258
self.msalClient?.getCurrentAccount(with: msalParameters, completionBlock: { (currentAccount, previousAccount, error) in
257259
if let error = error {
260+
if let completion = completion {
261+
completion(nil)
262+
}
263+
258264
return
259265
}
260266

@@ -313,7 +319,8 @@ public class MsalPlugin: CAPPlugin {
313319
#endif
314320

315321
let parameters = MSALInteractiveTokenParameters(scopes: self.msalPopupScopes!, webviewParameters: webViewParameters)
316-
parameters.promptType = .selectAccount
322+
parameters.promptType = .default
323+
parameters.completionBlockQueue = DispatchQueue.main
317324

318325
// 3. Acquire Token view Redirect Login through Microsft Identity Platform
319326
self.msalClient?.acquireToken(with: parameters) { (response, error) in

src/msal-capacitor-plugin/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)