Skip to content

Commit 1154cb4

Browse files
spetrescu84nilo-ms
andauthored
[IOS SDK] Just In Time registration (#2596)
* Native auth: Just in time SDK mock interface (#2555) * add new state and delegate for JIT * add mock implementation and update for signIn after singUp and SSPR delegates * Add callback also to signIn password delegate * make jit state methods public * use right callback method name * [iOS SDK] JIT Registration, Network implementation (#2576) * Added JIT classes * Jit classes * Controllers * New controllers * Moved controller * Changes for PR * Cleanup * Revert controller changes * Reverted changes on dispatchers * Fixed unit tests * remove non network files * Unit tests * Removed failing tests * PR comments * PR Comments * Swiftlint * Unit tests * Add error validation for invalid verification contact * Update MSAL/src/native_auth/public/state_machine/delegate_dispatcher/SignInDelegateDispatchers.swift Co-authored-by: Danilo Raspa <[email protected]> * Update MSAL/src/native_auth/public/state_machine/delegate_dispatcher/SignInDelegateDispatchers.swift Co-authored-by: Danilo Raspa <[email protected]> * Moved code to KnonwnESTSAPIErrorCodes * Moved to error case * Integration tests * Added comment --------- Co-authored-by: Danilo Raspa <[email protected]> * [iOS SDK] JIT Registration, Business implementation (#2583) * Added JIT classes * Jit classes * Controllers * New controllers * Moved controller * Changes for PR * Cleanup * Revert controller changes * Reverted changes on dispatchers * Fixed unit tests * remove non network files * Unit tests * Removed failing tests * PR comments * PR Comments * Swiftlint * Unit tests * Add error validation for invalid verification contact * Update MSAL/src/native_auth/public/state_machine/delegate_dispatcher/SignInDelegateDispatchers.swift Co-authored-by: Danilo Raspa <[email protected]> * Update MSAL/src/native_auth/public/state_machine/delegate_dispatcher/SignInDelegateDispatchers.swift Co-authored-by: Danilo Raspa <[email protected]> * Moved code to KnonwnESTSAPIErrorCodes * Moved to error case * Controller code * Linked controllers * Fix infinite allocation loop and empty verification contact * New SignIn method * Fix Unit tests * Removed not needed code * Split functions to handlers for responses * Update MSAL/src/native_auth/controllers/jit/MSALNativeAuthJITController.swift Co-authored-by: Danilo Raspa <[email protected]> * Removed unused parameter * Removed not needed swiftlint * Removed not needed username * Changed general error to browser required * removed not needed config * Renamed jitRequired to jitAuthMethodsSelectionRequired Moved logic to jitcontroller * changed incorrect error * Added preverified path * refactor, remove task inside of task * Finished moving away from the on... parameters Combined both signIn functions from the protocol into one * Removed redirect case from introspect endpoints * Renamed to HandleTokenResult * Integration tests * Added comment * Unit tests * Unit tests * PR Comments --------- Co-authored-by: Danilo Raspa <[email protected]> Co-authored-by: Danilo Raspa <[email protected]> * IC * Removed incorrect unit test host * Removed incorrect extra msal.framework * Swiftlint * Preverified --------- Co-authored-by: Danilo Raspa <[email protected]> Co-authored-by: Danilo Raspa <[email protected]>
1 parent 5ba49ef commit 1154cb4

File tree

79 files changed

+4569
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4569
-214
lines changed

MSAL/MSAL.xcodeproj/project.pbxproj

Lines changed: 332 additions & 44 deletions
Large diffs are not rendered by default.

MSAL/src/native_auth/controllers/MSALNativeAuthTokenController.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ class MSALNativeAuthTokenController: MSALNativeAuthBaseController {
5353

5454
func performAndValidateTokenRequest(
5555
_ request: MSIDHttpRequest,
56-
config: MSIDConfiguration,
5756
context: MSALNativeAuthRequestContext) async -> MSALNativeAuthTokenValidatedResponse {
5857
let ciamTokenResponse: Result<MSIDCIAMTokenResponse, Error> = await performTokenRequest(request, context: context)
5958
return responseValidator.validate(
6059
context: context,
61-
msidConfiguration: config,
6260
result: ciamTokenResponse
6361
)
6462
}
@@ -76,7 +74,7 @@ class MSALNativeAuthTokenController: MSALNativeAuthBaseController {
7674
func createTokenRequest(
7775
username: String? = nil,
7876
password: String? = nil,
79-
scopes: [String],
77+
scopes: [String]? = nil,
8078
continuationToken: String? = nil,
8179
oobCode: String? = nil,
8280
grantType: MSALNativeAuthGrantType,
@@ -89,7 +87,7 @@ class MSALNativeAuthTokenController: MSALNativeAuthBaseController {
8987
username: username,
9088
continuationToken: continuationToken,
9189
grantType: grantType,
92-
scope: scopes.joinScopes(),
90+
scope: scopes?.joinScopes(),
9391
password: password,
9492
oobCode: oobCode,
9593
includeChallengeType: includeChallengeType,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
protocol MSALNativeAuthControllerBuildable {
2626
func makeSignUpController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthSignUpControlling
2727
func makeSignInController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthSignInControlling
28+
func makeJITController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthJITControlling
2829
func makeResetPasswordController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthResetPasswordControlling
2930
func makeCredentialsController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthCredentialsControlling
3031
}
@@ -44,6 +45,10 @@ final class MSALNativeAuthControllerFactory: MSALNativeAuthControllerBuildable {
4445
return MSALNativeAuthSignInController(config: config, cacheAccessor: cacheAccessor)
4546
}
4647

48+
func makeJITController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthJITControlling {
49+
return MSALNativeAuthJITController(config: config, cacheAccessor: cacheAccessor)
50+
}
51+
4752
func makeResetPasswordController(cacheAccessor: MSALNativeAuthCacheInterface) -> MSALNativeAuthResetPasswordControlling {
4853
return MSALNativeAuthResetPasswordController(config: config, cacheAccessor: cacheAccessor)
4954
}

MSAL/src/native_auth/controllers/jit/MSALNativeAuthJITController.swift

Lines changed: 359 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
import Foundation
26+
27+
protocol MSALNativeAuthJITControlling {
28+
typealias JITGetJITAuthMethodsControllerResponse = MSALNativeAuthControllerTelemetryWrapper<JITRequestGetAuthMethodsResult>
29+
typealias JITRequestChallengeControllerResponse = MSALNativeAuthControllerTelemetryWrapper<JITRequestChallengeResult>
30+
typealias JITSubmitChallengeControllerResponse = MSALNativeAuthControllerTelemetryWrapper<JITSubmitChallengeResult>
31+
32+
func getJITAuthMethods(
33+
continuationToken: String,
34+
context: MSALNativeAuthRequestContext
35+
) async -> JITGetJITAuthMethodsControllerResponse
36+
37+
func requestJITChallenge(
38+
continuationToken: String,
39+
authMethod: MSALAuthMethod,
40+
verificationContact: String?,
41+
context: MSALNativeAuthRequestContext
42+
) async -> JITRequestChallengeControllerResponse
43+
44+
func submitJITChallenge(
45+
challenge: String?,
46+
continuationToken: String,
47+
grantType: MSALNativeAuthGrantType,
48+
context: MSALNativeAuthRequestContext
49+
) async -> JITSubmitChallengeControllerResponse
50+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
import Foundation
26+
27+
enum JITRequestGetAuthMethodsResult {
28+
case selectionRequired(authMethods: [MSALAuthMethod], newState: RegisterStrongAuthState)
29+
case error(error: MSALNativeAuthJITIntrospectValidatedErrorType)
30+
}
31+
32+
enum JITRequestChallengeResult {
33+
case verificationRequired(sentTo: String,
34+
channelTargetType: MSALNativeAuthChannelType,
35+
codeLength: Int,
36+
newState: RegisterStrongAuthVerificationRequiredState)
37+
case completed(MSALNativeAuthUserAccountResult)
38+
case error(error: RegisterStrongAuthChallengeError, newState: RegisterStrongAuthState?)
39+
}
40+
41+
enum JITSubmitChallengeResult {
42+
case completed(MSALNativeAuthUserAccountResult)
43+
case error(error: RegisterStrongAuthSubmitChallengeError, newState: RegisterStrongAuthVerificationRequiredState?)
44+
}

MSAL/src/native_auth/controllers/responses/SignInResults.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum SignInStartResult {
2929
case codeRequired(newState: SignInCodeRequiredState, sentTo: String, channelTargetType: MSALNativeAuthChannelType, codeLength: Int)
3030
case passwordRequired(newState: SignInPasswordRequiredState)
3131
case awaitingMFA(newState: AwaitingMFAState)
32+
case jitAuthMethodsSelectionRequired(authMethods: [MSALAuthMethod], newState: RegisterStrongAuthState)
3233
case error(SignInStartError)
3334
}
3435

@@ -37,6 +38,7 @@ typealias SignInResendCodeResult = CodeRequiredGenericResult<SignInCodeRequiredS
3738
enum SignInPasswordRequiredResult {
3839
case completed(MSALNativeAuthUserAccountResult)
3940
case awaitingMFA(newState: AwaitingMFAState)
41+
case jitAuthMethodsSelectionRequired(authMethods: [MSALAuthMethod], newState: RegisterStrongAuthState)
4042
case error(error: PasswordRequiredError, newState: SignInPasswordRequiredState?)
4143
}
4244

0 commit comments

Comments
 (0)