Skip to content

Commit 4665b35

Browse files
authored
Merge pull request #2582 from AzureAD/yuki/remove-legacy-interface
Native Auth remove legacy interface
2 parents a9f918b + 2bf3395 commit 4665b35

12 files changed

+222
-237
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [1.9.0]
22
* Add feature flags provider to be controlled from broker (#2540)
33
* Added GitHub issue templates for better issue tracking and reporting (#2554)
4+
* Removed deprecated methods from native auth public interface (#2582)
45

56
## [1.8.1]
67
* Cherry pick DUNA "resume" action fix #2558

MSAL/src/native_auth/public/MSALNativeAuthPublicClientApplication.swift

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -184,33 +184,6 @@ public final class MSALNativeAuthPublicClientApplication: MSALPublicClientApplic
184184
}
185185
}
186186

187-
/// Sign up a user with a given username and password.
188-
/// - Parameters:
189-
/// - username: Username for the new account.
190-
/// - password: Optional. Password to be used for the new account.
191-
/// - attributes: Optional. User attributes to be used during account creation.
192-
/// - correlationId: Optional. UUID to correlate this request with the server for debugging.
193-
/// - delegate: Delegate that receives callbacks for the Sign Up flow.
194-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'signUp(parameters:)' instead.")
195-
public func signUp(
196-
username: String,
197-
password: String? = nil,
198-
attributes: [String: Any]? = nil,
199-
correlationId: UUID? = nil,
200-
delegate: SignUpStartDelegate
201-
) {
202-
Task {
203-
let parameters = MSALNativeAuthSignUpParameters(username: username)
204-
parameters.password = password
205-
parameters.attributes = attributes
206-
parameters.correlationId = correlationId
207-
signUp(
208-
parameters: parameters,
209-
delegate: delegate
210-
)
211-
}
212-
}
213-
214187
/// Sign in a user using parameters.
215188
/// - Parameters:
216189
/// - parameters: Parameters used for the Sign In flow.
@@ -252,31 +225,6 @@ public final class MSALNativeAuthPublicClientApplication: MSALPublicClientApplic
252225
}
253226
}
254227

255-
/// Sign in a user with a given username and password.
256-
/// - Parameters:
257-
/// - username: Username for the account
258-
/// - password: Optional. Password for the account.
259-
/// - scopes: Optional. Permissions you want included in the access token received after sign in flow has completed.
260-
/// - correlationId: Optional. UUID to correlate this request with the server for debugging.
261-
/// - delegate: Delegate that receives callbacks for the Sign In flow.
262-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'signIn(parameters:)' instead.")
263-
public func signIn(
264-
username: String,
265-
password: String? = nil,
266-
scopes: [String]? = nil,
267-
correlationId: UUID? = nil,
268-
delegate: SignInStartDelegate
269-
) {
270-
let parameters = MSALNativeAuthSignInParameters(username: username)
271-
parameters.password = password
272-
parameters.scopes = scopes
273-
parameters.correlationId = correlationId
274-
signIn(
275-
parameters: parameters,
276-
delegate: delegate
277-
)
278-
}
279-
280228
/// Reset the password using parameters
281229
/// - Parameters:
282230
/// - parameters: Parameters used for the Reset Password flow.
@@ -306,25 +254,6 @@ public final class MSALNativeAuthPublicClientApplication: MSALPublicClientApplic
306254
}
307255
}
308256

309-
/// Reset the password for a given username.
310-
/// - Parameters:
311-
/// - username: Username for the account.
312-
/// - correlationId: Optional. UUID to correlate this request with the server for debugging.
313-
/// - delegate: Delegate that receives callbacks for the Reset Password flow.
314-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'resetPassword(parameters:)' instead.")
315-
public func resetPassword(
316-
username: String,
317-
correlationId: UUID? = nil,
318-
delegate: ResetPasswordStartDelegate
319-
) {
320-
let parameters = MSALNativeAuthResetPasswordParameters(username: username)
321-
parameters.correlationId = correlationId
322-
resetPassword(
323-
parameters: parameters,
324-
delegate: delegate
325-
)
326-
}
327-
328257
/// Retrieve the current signed in account from the cache.
329258
/// - Parameter correlationId: Optional. UUID to correlate this request with the server for debugging.
330259
/// - Returns: An object representing the account information if present in the local cache.

MSAL/src/native_auth/public/MSALNativeAuthUserAccountResult.swift

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -96,59 +96,4 @@ import Foundation
9696
correlationId: parameters.correlationId,
9797
delegate: delegate)
9898
}
99-
100-
/// Retrieves the access token for the default OIDC(openid, offline_access, profile) scopes from the cache.
101-
/// - Parameters:
102-
/// - forceRefresh: Optional. Ignore any existing access token in the cache and force MSAL to get a new access token from the service.
103-
/// - correlationId: Optional. UUID to correlate this request with the server for debugging.
104-
/// - delegate: Delegate that receives callbacks for the Get Access Token flow.
105-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'getAccessToken(parameters:)' instead.")
106-
@objc public func getAccessToken(forceRefresh: Bool = false,
107-
correlationId: UUID? = nil,
108-
delegate: CredentialsDelegate) {
109-
MSALNativeAuthLogger.log(
110-
level: .info,
111-
context: nil,
112-
format: "Retrieving access token without scopes.")
113-
114-
getAccessTokenInternal(forceRefresh: forceRefresh,
115-
scopes: [],
116-
claimsRequest: nil,
117-
correlationId: correlationId,
118-
delegate: delegate)
119-
}
120-
121-
/// Retrieves the access token for the currently signed in account from the cache such that
122-
/// the scope of retrieved access token is a superset of requested scopes. If the access token
123-
/// has expired, it will be refreshed using the refresh token that's stored in the cache. If no
124-
/// access token matching the requested scopes is found in cache then a new access token is fetched.
125-
/// - Parameters:
126-
/// - scopes: Permissions you want included in the access token received in the result. Not all scopes are guaranteed to be included in the access token returned.
127-
/// - forceRefresh: Optional. Ignore any existing access token in the cache and force MSAL to get a new access token from the service.
128-
/// - correlationId: Optional. UUID to correlate this request with the server for debugging.
129-
/// - delegate: Delegate that receives callbacks for the Get Access Token flow.
130-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'getAccessToken(parameters:)' instead.")
131-
public func getAccessToken(scopes: [String],
132-
forceRefresh: Bool = false,
133-
correlationId: UUID? = nil,
134-
delegate: CredentialsDelegate) {
135-
136-
guard inputValidator.isInputValid(scopes) else {
137-
Task { await delegate.onAccessTokenRetrieveError(error: RetrieveAccessTokenError(type: .invalidScope,
138-
correlationId: correlationId ?? UUID())) }
139-
return
140-
}
141-
142-
MSALNativeAuthLogger.log(
143-
level: .info,
144-
context: nil,
145-
format: "Retrieving access token with scopes started."
146-
)
147-
148-
getAccessTokenInternal(forceRefresh: forceRefresh,
149-
scopes: scopes,
150-
claimsRequest: nil,
151-
correlationId: correlationId,
152-
delegate: delegate)
153-
}
15499
}

MSAL/src/native_auth/public/state_machine/state/SignInAfterResetPasswordState.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,4 @@ import Foundation
5656
}
5757
}
5858
}
59-
60-
/// Sign in the user that just reset the password.
61-
/// - Parameters:
62-
/// - scopes: Optional. Permissions you want included in the access token received after sign in flow has completed.
63-
/// - delegate: Delegate that receives callbacks for the Sign In flow.
64-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'signIn(parameters:)' instead.")
65-
public func signIn(scopes: [String]? = nil, delegate: SignInAfterResetPasswordDelegate) {
66-
let parameters = MSALNativeAuthSignInAfterResetPasswordParameters()
67-
parameters.scopes = scopes
68-
signIn(
69-
parameters: parameters,
70-
delegate: delegate
71-
)
72-
}
7359
}

MSAL/src/native_auth/public/state_machine/state/SignInAfterSignUpState.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,4 @@ import Foundation
5151
}
5252
}
5353
}
54-
55-
/// Sign in the user that signed up.
56-
/// - Parameters:
57-
/// - scopes: Optional. Permissions you want included in the access token received after sign in flow has completed.
58-
/// - delegate: Delegate that receives callbacks for the Sign In flow.
59-
@available(*, deprecated, message: "This method is now deprecated. Use the method 'signIn(parameters:)' instead.")
60-
public func signIn(scopes: [String]? = nil, delegate: SignInAfterSignUpDelegate) {
61-
let parameters = MSALNativeAuthSignInAfterSignUpParameters()
62-
parameters.scopes = scopes
63-
signIn(
64-
parameters: parameters,
65-
delegate: delegate)
66-
}
6754
}

MSAL/test/integration/native_auth/end_to_end/credentials/MSALNativeAuthUserAccountEndToEndTests.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ final class MSALNativeAuthUserAccountEndToEndTests: MSALNativeAuthEndToEndPasswo
119119
let signInExpectation = expectation(description: "signing in")
120120
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
121121

122-
sut.signIn(username: username, password: password, scopes: ["User.Read"], correlationId: correlationId, delegate: signInDelegateSpy)
122+
let params = MSALNativeAuthSignInParameters(username: username)
123+
params.password = password
124+
params.scopes = ["User.Read"]
125+
params.correlationId = correlationId
126+
sut.signIn(parameters: params, delegate: signInDelegateSpy)
123127

124128
await fulfillment(of: [signInExpectation])
125129

@@ -130,7 +134,9 @@ final class MSALNativeAuthUserAccountEndToEndTests: MSALNativeAuthEndToEndPasswo
130134
let getAccessTokenExpectation = expectation(description: "getting access token")
131135
let credentialsDelegateSpy = CredentialsDelegateSpy(expectation: getAccessTokenExpectation)
132136

133-
signInDelegateSpy.result?.getAccessToken(scopes: ["User.Read"], delegate: credentialsDelegateSpy)
137+
let getTokenParam = MSALNativeAuthGetAccessTokenParameters()
138+
getTokenParam.scopes = ["User.Read"]
139+
signInDelegateSpy.result?.getAccessToken(parameters: getTokenParam, delegate: credentialsDelegateSpy)
134140

135141
await fulfillment(of: [getAccessTokenExpectation])
136142

MSAL/test/integration/native_auth/end_to_end/reset_password/MSALNativeAuthResetPasswordEndToEndTests.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
8686
let codeRequiredExp = expectation(description: "code required")
8787
let resetPasswordStartDelegate = ResetPasswordStartDelegateSpy(expectation: codeRequiredExp)
8888

89-
sut.resetPassword(username: username, delegate: resetPasswordStartDelegate)
89+
let param = MSALNativeAuthResetPasswordParameters(username: username)
90+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
9091

9192
await fulfillment(of: [codeRequiredExp])
9293
XCTAssertTrue(resetPasswordStartDelegate.onResetPasswordCodeRequiredCalled)
@@ -130,7 +131,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
130131
let codeRequiredExp = expectation(description: "code required")
131132
let resetPasswordStartDelegate = ResetPasswordStartDelegateSpy(expectation: codeRequiredExp)
132133

133-
sut.resetPassword(username: username, delegate: resetPasswordStartDelegate)
134+
let param = MSALNativeAuthResetPasswordParameters(username: username)
135+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
134136

135137
await fulfillment(of: [codeRequiredExp])
136138
XCTAssertTrue(resetPasswordStartDelegate.onResetPasswordCodeRequiredCalled)
@@ -196,7 +198,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
196198

197199
let unknownUsername = UUID().uuidString + "@contoso.com"
198200

199-
sut.resetPassword(username: unknownUsername, delegate: resetPasswordStartDelegate)
201+
let param = MSALNativeAuthResetPasswordParameters(username: unknownUsername)
202+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
200203

201204
await fulfillment(of: [resetPasswordFailureExp])
202205

@@ -217,7 +220,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
217220
let resetPasswordFailureExp = expectation(description: "reset password web-fallback")
218221
let resetPasswordStartDelegate = ResetPasswordStartDelegateSpy(expectation: resetPasswordFailureExp)
219222

220-
sut.resetPassword(username: username, delegate: resetPasswordStartDelegate)
223+
let param = MSALNativeAuthResetPasswordParameters(username: username)
224+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
221225

222226
await fulfillment(of: [resetPasswordFailureExp])
223227

@@ -238,7 +242,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
238242
let resetPasswordFailureExp = expectation(description: "does not support password")
239243
let resetPasswordStartDelegate = ResetPasswordStartDelegateSpy(expectation: resetPasswordFailureExp)
240244

241-
sut.resetPassword(username: username, delegate: resetPasswordStartDelegate)
245+
let param = MSALNativeAuthResetPasswordParameters(username: username)
246+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
242247

243248
await fulfillment(of: [resetPasswordFailureExp])
244249

@@ -261,7 +266,8 @@ final class MSALNativeAuthResetPasswordEndToEndTests: MSALNativeAuthEndToEndBase
261266
let resetPasswordFailureExp = expectation(description: "reset password user not found")
262267
let resetPasswordStartDelegate = ResetPasswordStartDelegateSpy(expectation: resetPasswordFailureExp)
263268

264-
sut.resetPassword(username: username, delegate: resetPasswordStartDelegate)
269+
let param = MSALNativeAuthResetPasswordParameters(username: username)
270+
sut.resetPassword(parameters: param, delegate: resetPasswordStartDelegate)
265271

266272
await fulfillment(of: [resetPasswordFailureExp])
267273

MSAL/test/integration/native_auth/end_to_end/sign_in/MSALNativeAuthSignInUserNameAndPasswordEndToEndTests.swift

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
4040
let signInExpectation = expectation(description: "signing in")
4141
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
4242

43-
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy)
43+
let parameters = MSALNativeAuthSignInParameters(username: username)
44+
parameters.password = password
45+
parameters.correlationId = correlationId
46+
sut.signIn(parameters: parameters, delegate: signInDelegateSpy)
4447

4548
await fulfillment(of: [signInExpectation])
4649

@@ -81,8 +84,11 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
8184

8285
let signInExpectation = expectation(description: "signing in")
8386
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
84-
85-
sut.signIn(username: username, password: "An Invalid Password", correlationId: correlationId, delegate: signInDelegateSpy)
87+
88+
let signInParam = MSALNativeAuthSignInParameters(username: username)
89+
signInParam.password = "An Invalid Password"
90+
signInParam.correlationId = correlationId
91+
sut.signIn(parameters: signInParam, delegate: signInDelegateSpy)
8692

8793
await fulfillment(of: [signInExpectation])
8894

@@ -108,7 +114,6 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
108114
let signInParam = MSALNativeAuthSignInParameters(username: username)
109115
signInParam.password = password
110116
signInParam.correlationId = correlationId
111-
112117
sut.signIn(parameters: signInParam, delegate: signInDelegateSpy)
113118

114119
await fulfillment(of: [signInExpectation])
@@ -121,7 +126,10 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
121126
let signInExpectation2 = expectation(description: "signing in")
122127
let signInDelegateSpy2 = SignInPasswordStartDelegateSpy(expectation: signInExpectation2)
123128

124-
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy2)
129+
let signInParam2 = MSALNativeAuthSignInParameters(username: username)
130+
signInParam2.password = password
131+
signInParam2.correlationId = correlationId
132+
sut.signIn(parameters: signInParam2, delegate: signInDelegateSpy2)
125133

126134
XCTAssertTrue(signInDelegateSpy.onSignInCompletedCalled)
127135
XCTAssertNotNil(signInDelegateSpy.result?.idToken)
@@ -140,7 +148,10 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
140148
let signInExpectation = expectation(description: "signing in")
141149
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
142150

143-
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy)
151+
let signInParam = MSALNativeAuthSignInParameters(username: username)
152+
signInParam.password = password
153+
signInParam.correlationId = correlationId
154+
sut.signIn(parameters: signInParam, delegate: signInDelegateSpy)
144155

145156
await fulfillment(of: [signInExpectation])
146157

@@ -152,7 +163,9 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
152163
let signInExpectation2 = expectation(description: "signing in")
153164
let signInDelegateSpy2 = SignInStartDelegateSpy(expectation: signInExpectation)
154165

155-
sut.signIn(username: username2, correlationId: correlationId, delegate: signInDelegateSpy2)
166+
let signInParam2 = MSALNativeAuthSignInParameters(username: username2)
167+
signInParam2.correlationId = correlationId
168+
sut.signIn(parameters: signInParam2, delegate: signInDelegateSpy2)
156169

157170
await fulfillment(of: [signInExpectation2])
158171

@@ -181,7 +194,11 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
181194
/* User Case 1.2.6. Sign In - Ability to provide scope to control auth strength of the token
182195
Please refer to Crendentials test (test_signInWithExtraScopes())
183196

184-
sut.signIn(username: username, password: password, scopes: ["User.Read"], correlationId: correlationId, delegate: signInDelegateSpy)
197+
let signInParam = MSALNativeAuthSignInParameters(username: username)
198+
signInParam.password = password
199+
signInParam.correlationId = correlationId
200+
sut.signIn(parameters: signInParam, delegate: signInDelegateSpy)
201+
185202
...
186203
XCTAssertTrue(credentialsDelegateSpy.result!.scopes.contains("User.Read"))
187204
*/
@@ -198,7 +215,10 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
198215
let signInExpectation = expectation(description: "signing in")
199216
let signInDelegateSpy = SignInStartDelegateSpy(expectation: signInExpectation)
200217

201-
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy)
218+
let signInParam = MSALNativeAuthSignInParameters(username: username)
219+
signInParam.password = password
220+
signInParam.correlationId = correlationId
221+
sut.signIn(parameters: signInParam, delegate: signInDelegateSpy)
202222

203223
await fulfillment(of: [signInExpectation])
204224

0 commit comments

Comments
 (0)