Skip to content

Commit 0a192c2

Browse files
antrix1989ameyapatantonioalwanhieunguyenmsftiambmelt
authored
Merge release 1.3.3 to main (#2165)
* Update msal-release-ado-trigger.yml for Azure Pipelines * Update msal-release-ado-trigger.yml for Azure Pipelines * Update msal-release-ado-trigger.yml for Azure Pipelines * Update msal-release-ado-trigger.yml for Azure Pipelines * Update msal-release-ado-trigger.yml for Azure Pipelines * Update msal-release-ado-trigger.yml for Azure Pipelines * Delete spm-framework.yml * Update from dev * remove test * Reintroduce Minimum OS Version Requirements to Readme Reintroducing minimum version indicators that were [mistakenly?] removed in #2080 * So support ssh-cert flow through broker (Update submodule only) (#2134) * cc update * Update submodule * Update submodule * ID Token should be updated when Access Token is refreshed/acquired silently (#2141) * Changed refresh token to update account and tokens on UserAccountResult * Unit tests * Swiftlint * Updated code comment * PR Comments * Update automation.yml for Azure Pipelines * Update automation.yml for Azure Pipelines * Update automation.yml for Azure Pipelines * This PR removes the ADAL keyvault and client secret (#2150) * Update submodule * Update yml file * Revert conf file from testings * Update msal submodule (#2160) * Update core. * Bump version. * modified: CHANGELOG.md * modified: IdentityCore --------- Co-authored-by: Ameya Patil <[email protected]> Co-authored-by: Ameya <> Co-authored-by: Antonio Alwan <[email protected]> Co-authored-by: Hieu Nguyen <[email protected]> Co-authored-by: Ameya Patil <[email protected]> Co-authored-by: Hieu Nguyen <[email protected]> Co-authored-by: Brian Melton-Grace <[email protected]> Co-authored-by: Kai <[email protected]> Co-authored-by: Silviu Petrescu <[email protected]> Co-authored-by: Swasti Gupta <[email protected]>
1 parent 2ac82ce commit 0a192c2

20 files changed

+191
-500
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.3.3]
2+
* Update common core submodule.
3+
* Automation improvements.
4+
15
## [1.3.2]
26
* Add forceRefresh param to ignore AT in cache and request a new AT.
37

MSAL.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MSAL"
3-
s.version = "1.3.2"
3+
s.version = "1.3.3"
44
s.summary = "Microsoft Authentication Library (MSAL) for iOS"
55
s.description = <<-DESC
66
The MSAL library for iOS gives your app the ability to begin using the Microsoft Cloud by supporting Microsoft Azure Active Directory and Microsoft Accounts in a converged experience using industry standard OAuth2 and OpenID Connect. The library also supports Microsoft Azure B2C for those using our hosted identity management service.

MSAL/IdentityCore

Submodule IdentityCore updated 33 files

MSAL/MSAL.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@
761761
B2C17B0A1FC8DB2E0070A514 /* MSIDVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C17B091FC8DB2E0070A514 /* MSIDVersion.m */; };
762762
B2C17B0B1FC8DB2E0070A514 /* MSIDVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C17B091FC8DB2E0070A514 /* MSIDVersion.m */; };
763763
B2D0A38321C708CF0071E0DA /* MSALADFSv4FederatedTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B21F9DE72120E85100B1B40C /* MSALADFSv4FederatedTests.m */; };
764-
B2D0A38821C709C30071E0DA /* MSALShibUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = B21F9DEE2120F0E800B1B40C /* MSALShibUITests.m */; };
765764
B2D0A38A21C70AF50071E0DA /* MSALPingUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = B21F9DEC2120EB3E00B1B40C /* MSALPingUITests.m */; };
766765
B2D0A38E21C71B8C0071E0DA /* MSALGuestUserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B21F9DF02120F5CE00B1B40C /* MSALGuestUserTests.m */; };
767766
B2D0A38F21C71D900071E0DA /* MSALCacheRemovalTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C232AA2122A6A5008092C1 /* MSALCacheRemovalTests.m */; };
@@ -5555,7 +5554,6 @@
55555554
B2A1C33F21C7038D00DDAE8E /* MSALADFSv3FederatedTests.m in Sources */,
55565555
B2F4572A211C0B4800818910 /* MSALBaseAADUITest.m in Sources */,
55575556
B282255C23EF811F0007DFE4 /* MSALB2CInteractiveTests.m in Sources */,
5558-
B2D0A38821C709C30071E0DA /* MSALShibUITests.m in Sources */,
55595557
B2BB73732112C32C000EA4C5 /* MSALAADBasicInteractiveTests.m in Sources */,
55605558
B2D0A38E21C71B8C0071E0DA /* MSALGuestUserTests.m in Sources */,
55615559
B2D0A39221C72C740071E0DA /* MSALMSABasicInteractiveTests.m in Sources */,

MSAL/resources/ios/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3.2</string>
18+
<string>1.3.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

MSAL/resources/mac/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3.2</string>
18+
<string>1.3.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>

MSAL/src/MSAL_Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define MSAL_VER_HIGH 1
2929
#define MSAL_VER_LOW 3
30-
#define MSAL_VER_PATCH 2
30+
#define MSAL_VER_PATCH 3
3131

3232
#define STR_HELPER(x) #x
3333
#define STR(x) STR_HELPER(x)

MSAL/src/native_auth/controllers/credentials/MSALNativeAuthCredentialsController.swift

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ final class MSALNativeAuthCredentialsController: MSALNativeAuthTokenController,
8383
return nil
8484
}
8585

86-
func refreshToken(context: MSALNativeAuthRequestContext, authTokens: MSALNativeAuthTokens) async -> RefreshTokenCredentialControllerResponse {
86+
func refreshToken(context: MSALNativeAuthRequestContext,
87+
authTokens: MSALNativeAuthTokens,
88+
userAccountResult: MSALNativeAuthUserAccountResult) async -> RefreshTokenCredentialControllerResponse {
8789
MSALLogger.log(level: .verbose, context: context, format: "Refresh started")
8890
let telemetryEvent = makeAndStartTelemetryEvent(id: .telemetryApiIdRefreshToken, context: context)
8991
let scopes = authTokens.accessToken.scopes.array as? [String] ?? []
@@ -104,7 +106,8 @@ final class MSALNativeAuthCredentialsController: MSALNativeAuthTokenController,
104106
response,
105107
scopes: scopes,
106108
context: context,
107-
telemetryEvent: telemetryEvent
109+
telemetryEvent: telemetryEvent,
110+
userAccountResult: userAccountResult
108111
)
109112
}
110113

@@ -147,7 +150,8 @@ final class MSALNativeAuthCredentialsController: MSALNativeAuthTokenController,
147150
_ response: MSALNativeAuthTokenValidatedResponse,
148151
scopes: [String],
149152
context: MSALNativeAuthRequestContext,
150-
telemetryEvent: MSIDTelemetryAPIEvent?
153+
telemetryEvent: MSIDTelemetryAPIEvent?,
154+
userAccountResult: MSALNativeAuthUserAccountResult
151155
) -> RefreshTokenCredentialControllerResponse {
152156
let config = factory.makeMSIDConfiguration(scopes: scopes)
153157
switch response {
@@ -156,7 +160,8 @@ final class MSALNativeAuthCredentialsController: MSALNativeAuthTokenController,
156160
tokenResponse: tokenResponse,
157161
telemetryEvent: telemetryEvent,
158162
context: context,
159-
config: config
163+
config: config,
164+
userAccountResult: userAccountResult
160165
)
161166
case .error(let errorType):
162167
let error = errorType.convertToRetrieveAccessTokenError(correlationId: context.correlationId())
@@ -173,21 +178,23 @@ final class MSALNativeAuthCredentialsController: MSALNativeAuthTokenController,
173178
tokenResponse: MSIDTokenResponse,
174179
telemetryEvent: MSIDTelemetryAPIEvent?,
175180
context: MSALNativeAuthRequestContext,
176-
config: MSIDConfiguration
181+
config: MSIDConfiguration,
182+
userAccountResult: MSALNativeAuthUserAccountResult
177183
) -> RefreshTokenCredentialControllerResponse {
178184
do {
179185
let tokenResult = try cacheTokenResponse(tokenResponse, context: context, msidConfiguration: config)
180-
MSALLogger.log(
181-
level: .verbose,
182-
context: context,
183-
format: "Refresh Token completed successfully")
184-
// TODO: Handle tokenResult.refreshToken as? MSIDRefreshToken in a safer way
185-
return .init(
186-
.success(MSALNativeAuthTokenResult(authTokens: MSALNativeAuthTokens(
187-
accessToken: tokenResult.accessToken,
188-
refreshToken: tokenResult.refreshToken as? MSIDRefreshToken,
189-
rawIdToken: tokenResult.rawIdToken
190-
))),
186+
let account = factory.makeAccount(tokenResult: tokenResult, context: context)
187+
guard let authTokens = factory.makeAuthTokens(tokenResult: tokenResult, context: context) else {
188+
let error = RetrieveAccessTokenError(type: .generalError, correlationId: context.correlationId())
189+
MSALLogger.log(
190+
level: .error,
191+
context: context,
192+
format: "Auth Tokens could not be created")
193+
stopTelemetryEvent(telemetryEvent, context: context, error: error)
194+
return .init(.failure(error), correlationId: context.correlationId())
195+
}
196+
userAccountResult.refreshData(authTokens: authTokens, account: account)
197+
return .init(.success(MSALNativeAuthTokenResult(authTokens: authTokens)),
191198
correlationId: context.correlationId(),
192199
telemetryUpdate: { [weak self] result in
193200
telemetryEvent?.setUserInformation(tokenResult.account)

MSAL/src/native_auth/controllers/credentials/MSALNativeAuthCredentialsControlling.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ protocol MSALNativeAuthCredentialsControlling {
2929
MSALNativeAuthControllerTelemetryWrapper<Result<MSALNativeAuthTokenResult, RetrieveAccessTokenError>>
3030

3131
func retrieveUserAccountResult(context: MSALNativeAuthRequestContext) -> MSALNativeAuthUserAccountResult?
32-
func refreshToken(context: MSALNativeAuthRequestContext, authTokens: MSALNativeAuthTokens) async -> RefreshTokenCredentialControllerResponse
32+
func refreshToken(context: MSALNativeAuthRequestContext,
33+
authTokens: MSALNativeAuthTokens,
34+
userAccountResult: MSALNativeAuthUserAccountResult) async -> RefreshTokenCredentialControllerResponse
3335
}

MSAL/src/native_auth/controllers/factories/MSALNativeAuthResultFactory.swift

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ protocol MSALNativeAuthResultBuildable {
2828

2929
var config: MSALNativeAuthConfiguration {get}
3030

31+
func makeAccount(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALAccount
32+
33+
func makeAuthTokens(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALNativeAuthTokens?
34+
3135
func makeUserAccountResult(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALNativeAuthUserAccountResult?
3236

3337
func makeUserAccountResult(account: MSALAccount, authTokens: MSALNativeAuthTokens) -> MSALNativeAuthUserAccountResult?
@@ -45,42 +49,50 @@ final class MSALNativeAuthResultFactory: MSALNativeAuthResultBuildable {
4549
self.cacheAccessor = cacheAccessor
4650
}
4751

48-
func makeUserAccountResult(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALNativeAuthUserAccountResult? {
52+
func makeAccount(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALAccount {
4953
var jsonDictionary: [AnyHashable: Any]?
5054
do {
5155
let claims = try MSIDIdTokenClaims.init(rawIdToken: tokenResult.rawIdToken)
5256
jsonDictionary = claims.jsonDictionary()
5357
if jsonDictionary == nil {
5458
MSALLogger.log(
55-
level: .error,
59+
level: .warning,
5660
context: context,
5761
format: "Initialising account without claims")
5862
}
5963
} catch {
6064
MSALLogger.log(
61-
level: .error,
65+
level: .warning,
6266
context: context,
6367
format: "Claims for account could not be created - \(error)" )
6468
}
65-
guard let account = MSALAccount.init(msidAccount: tokenResult.account,
66-
createTenantProfile: false,
67-
accountClaims: jsonDictionary) else {
69+
return MSALAccount.init(msidAccount: tokenResult.account,
70+
createTenantProfile: false,
71+
accountClaims: jsonDictionary)
72+
}
73+
74+
func makeAuthTokens(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALNativeAuthTokens? {
75+
guard let refreshToken = tokenResult.refreshToken as? MSIDRefreshToken else {
6876
MSALLogger.log(
6977
level: .error,
7078
context: context,
71-
format: "Account could not be created")
79+
format: "Refresh token invalid, account result could not be created")
7280
return nil
7381
}
74-
guard let refreshToken = tokenResult.refreshToken as? MSIDRefreshToken else {
82+
return MSALNativeAuthTokens(accessToken: tokenResult.accessToken,
83+
refreshToken: refreshToken,
84+
rawIdToken: tokenResult.rawIdToken)
85+
}
86+
87+
func makeUserAccountResult(tokenResult: MSIDTokenResult, context: MSIDRequestContext) -> MSALNativeAuthUserAccountResult? {
88+
let account = makeAccount(tokenResult: tokenResult, context: context)
89+
guard let authTokens = makeAuthTokens(tokenResult: tokenResult, context: context) else {
7590
MSALLogger.log(
7691
level: .error,
7792
context: context,
78-
format: "Refresh token invalid, account result could not be created")
93+
format: "Auth Tokens could not be created")
7994
return nil
8095
}
81-
let authTokens = MSALNativeAuthTokens(accessToken: tokenResult.accessToken,
82-
refreshToken: refreshToken,
83-
rawIdToken: tokenResult.rawIdToken)
8496
return .init(account: account, authTokens: authTokens, configuration: config, cacheAccessor: cacheAccessor)
8597
}
8698

0 commit comments

Comments
 (0)