Skip to content

Commit 10a2272

Browse files
committed
merge dev
2 parents 28f4682 + 1e16641 commit 10a2272

File tree

6 files changed

+128
-7
lines changed

6 files changed

+128
-7
lines changed

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.6.3"
3+
s.version = "1.7.0"
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/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.6.3</string>
18+
<string>1.7.0</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.6.3</string>
18+
<string>1.7.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>

MSAL/src/MSAL_Internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
//------------------------------------------------------------------------------
2727

2828
#define MSAL_VER_HIGH 1
29-
#define MSAL_VER_LOW 6
30-
#define MSAL_VER_PATCH 3
29+
#define MSAL_VER_LOW 7
30+
#define MSAL_VER_PATCH 0
3131

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

MSAL/test/integration/native_auth/end_to_end/mfa/MSALNativeAuthSignInWithMFAEndToEndTests.swift

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,128 @@ final class MSALNativeAuthSignInWithMFAEndToEndTests: MSALNativeAuthEndToEndPass
191191
// Now retrieve and submit the email OTP code
192192
await completeSignInWithMFAFlow(state: mfaRequiredState, username: username)
193193
}
194-
194+
195+
func test_signInAuthenticationContextClaim_mfaFlowIsTriggeredAndAccessTokenContainsClaims() async throws {
196+
throw XCTSkip("Retrieving OTP failure")
197+
#if os(macOS)
198+
throw XCTSkip("For some reason this test now requires Keychain access, reason needs to be investigated")
199+
#endif
200+
guard let username = retrieveUsernameForSignInUsernamePasswordAndMFA(),
201+
let password = await retrievePasswordForSignInUsername(),
202+
let application = initialisePublicClientApplication()
203+
else {
204+
XCTFail("Something went wrong")
205+
return
206+
}
207+
208+
let authenticationContextId = "c4"
209+
let authenticationContextRequestClaimJson = "{\"access_token\":{\"acrs\":{\"essential\":true,\"value\":\"\(authenticationContextId)\"}}}"
210+
let authenticationContextATClaimJson = "\"acrs\":[\"\(authenticationContextId)\"]"
211+
212+
let parameters = MSALNativeAuthSignInParameters(username: username)
213+
parameters.password = password
214+
var error: NSError? = nil
215+
216+
parameters.claimsRequest = MSALClaimsRequest(jsonString: authenticationContextRequestClaimJson,
217+
error: &error)
218+
219+
let signInExpectation = expectation(description: "signing in")
220+
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
221+
222+
application.signIn(parameters: parameters, delegate: signInDelegateSpy)
223+
224+
await fulfillment(of: [signInExpectation])
225+
226+
guard signInDelegateSpy.onSignInAwaitingMFACalled, let awaitingMFAState = signInDelegateSpy.newStateAwaitingMFA else {
227+
XCTFail("Awaiting MFA not called")
228+
return
229+
}
230+
231+
// Request to send challenge to the default strong auth method
232+
let mfaExpectation = expectation(description: "mfa")
233+
let mfaDelegateSpy = MFARequestChallengeDelegateSpy(expectation: mfaExpectation)
234+
235+
awaitingMFAState.requestChallenge(delegate: mfaDelegateSpy)
236+
237+
await fulfillment(of: [mfaExpectation])
238+
239+
guard mfaDelegateSpy.onSelectionRequiredCalled, let mfaRequiredState = mfaDelegateSpy.newStateMFARequired, let authMethod = mfaDelegateSpy.authMethods?.first else {
240+
XCTFail("Selection required not triggered")
241+
return
242+
}
243+
244+
XCTAssertTrue(authMethod.channelTargetType.isEmailType)
245+
246+
// Request to send challenge to a specific strong auth method
247+
248+
let mfaSendChallengeExpectation = expectation(description: "mfa")
249+
let mfaSendChallengeDelegateSpy = MFARequestChallengeDelegateSpy(expectation: mfaSendChallengeExpectation)
250+
mfaRequiredState.requestChallenge(authMethod: authMethod, delegate: mfaSendChallengeDelegateSpy)
251+
252+
await fulfillment(of: [mfaSendChallengeExpectation])
253+
254+
guard mfaSendChallengeDelegateSpy.onVerificationRequiredCalled, let newMfaRequiredState = mfaSendChallengeDelegateSpy.newStateMFARequired else {
255+
XCTFail("Challenge not sent to MFA method")
256+
return
257+
}
258+
259+
XCTAssertNotNil(mfaSendChallengeDelegateSpy.sentTo)
260+
XCTAssertNotNil(mfaSendChallengeDelegateSpy.codeLength)
261+
XCTAssertTrue(mfaSendChallengeDelegateSpy.channelTargetType!.isEmailType)
262+
263+
guard let code = await retrieveCodeFor(email: username) else {
264+
XCTFail("OTP code could not be retrieved")
265+
return
266+
}
267+
268+
let submitChallengeExpectation = expectation(description: "submitChallenge")
269+
let mfaSubmitChallengeDelegateSpy = MFASubmitChallengeDelegateSpy(expectation: submitChallengeExpectation)
270+
271+
newMfaRequiredState.submitChallenge(challenge: code, delegate: mfaSubmitChallengeDelegateSpy)
272+
273+
await fulfillment(of: [submitChallengeExpectation])
274+
275+
XCTAssertTrue(mfaSubmitChallengeDelegateSpy.onSignInCompletedCalled)
276+
XCTAssertNotNil(mfaSubmitChallengeDelegateSpy.result)
277+
XCTAssertNotNil(mfaSubmitChallengeDelegateSpy.result?.idToken)
278+
XCTAssertEqual(mfaSubmitChallengeDelegateSpy.result?.account.username, username)
279+
280+
let geAccessTokenExpectation = expectation(description: "get access token")
281+
let credentialsDelegateSpy = CredentialsDelegateSpy(expectation: geAccessTokenExpectation)
282+
283+
signInDelegateSpy.result?.getAccessToken(parameters: MSALNativeAuthGetAccessTokenParameters(), delegate: credentialsDelegateSpy)
284+
285+
await fulfillment(of: [geAccessTokenExpectation])
286+
287+
XCTAssertTrue(credentialsDelegateSpy.onAccessTokenRetrieveCompletedCalled)
288+
XCTAssertNotNil(credentialsDelegateSpy.result?.accessToken)
289+
290+
let atParts = credentialsDelegateSpy.result?.accessToken.components(separatedBy: ".")
291+
292+
// It should have 3 parts
293+
guard let atParts, atParts.count == 3 else {
294+
XCTFail("Invalid Access token received")
295+
return
296+
}
297+
298+
// We need to use the middle part
299+
var atBody: String! = atParts[1]
300+
301+
//There could be the case that the length of the access token is not a multiple of 4 so we pad it with "="
302+
let length = Double(atBody.lengthOfBytes(using: String.Encoding.utf8))
303+
let requiredLength = 4 * ceil(length / 4.0)
304+
let paddingLength = requiredLength - length
305+
if paddingLength > 0 {
306+
let padding = "".padding(toLength: Int(paddingLength), withPad: "=", startingAt: 0)
307+
atBody = atBody + padding
308+
}
309+
310+
let atEncodedData = Data(base64Encoded: atBody!, options: .ignoreUnknownCharacters)
311+
let atString = String(data: atEncodedData!, encoding: .utf8)!
312+
313+
XCTAssertTrue(atString.contains(authenticationContextATClaimJson))
314+
}
315+
195316
// MARK: private methods
196317

197318
private func signInUsernameAndPassword(username: String, password: String) async -> AwaitingMFAState? {

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ let package = Package(
1313
targets: ["MSAL"]),
1414
],
1515
targets: [
16-
.binaryTarget(name: "MSAL", url: "https://github.com/AzureAD/microsoft-authentication-library-for-objc/releases/download/1.6.2/MSAL.zip", checksum: "dbc4346f983e6402a37a747b371cadb44b39523a837d901e0ccc1c52b5d142d1")
16+
.binaryTarget(name: "MSAL", url: "https://github.com/AzureAD/microsoft-authentication-library-for-objc/releases/download/1.6.3/MSAL.zip", checksum: "ce2684b1d4ab1038d7ad892d4cae8a2ae38d0f13192064473a601fffe4ae755e")
1717
]
1818
)

0 commit comments

Comments
 (0)