-
Notifications
You must be signed in to change notification settings - Fork 247
My Account Auth APIs #974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
My Account Auth APIs #974
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the My Account Auth APIs Early Access release, adding comprehensive authentication method management capabilities to the Auth0 iOS SDK. The implementation includes support for multiple authentication factors (phone, TOTP, push notifications, passkeys, email, recovery codes) with enrollment, confirmation, retrieval, update, and deletion operations.
Key changes:
- Added enrollment and confirmation flows for TOTP, email, phone, push notifications, and recovery codes
- Implemented CRUD operations for authentication methods (get all, get by ID, update, delete)
- Added factor status retrieval functionality
- Updated URL structure to match the new API design
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
Auth0/MyAccount/AuthenticationMethods/ | New authentication method models and protocol implementations |
Auth0Tests/MyAccount/AuthenticationMethods/ | Comprehensive test coverage for all new API endpoints |
Auth0Tests/Responses.swift | Test response helpers for new authentication method types |
Auth0Tests/Matchers.swift | Test matchers for validation of new response types |
Auth0/MyAccount/MyAccountHandlers.swift | Added handler for no-body responses |
Auth0.xcodeproj/project.pbxproj | Project file updates for new source files |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Auth0/MyAccount/AuthenticationMethods/PhoneEmailChallenge.swift
Outdated
Show resolved
Hide resolved
case transports | ||
case confirmed | ||
case name | ||
case preferredAuthenticationMethod = "preferrred_authentication_method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spelling error in the CodingKeys mapping. "preferrred_authentication_method" should be "preferred_authentication_method" (missing one 'r').
case preferredAuthenticationMethod = "preferrred_authentication_method" | |
case preferredAuthenticationMethod = "preferred_authentication_method" |
Copilot uses AI. Check for mistakes.
}, response: totpPushEnrollmentChallengeResponse(id: AuthenticationMethodId, | ||
authSession: AuthSession, | ||
barcodeUri: barcodeUri, | ||
manualInoutcode: manualInputCode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name "manualInoutcode" should be "manualInputCode" to match the expected parameter name.
manualInoutcode: manualInputCode)) | |
manualInputCode: manualInputCode)) |
Copilot uses AI. Check for mistakes.
"auth_session": authSession, | ||
] | ||
if let uri = barcodeUri { payload["barcode_uri"] = uri } | ||
if let manualInoutcode = manualInoutcode { payload["manual_input_code"] = manualInoutcode } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name "manualInoutcode" should be "manualInputCode" for consistency and clarity.
if let manualInoutcode = manualInoutcode { payload["manual_input_code"] = manualInoutcode } | |
func totpPushEnrollmentChallengeResponse(id: String, authSession: String, barcodeUri: String? = nil, manualInputCode: String? = nil) -> RequestResponse { | |
var payload: [String: Any] = [ | |
"id": id, | |
"auth_session": authSession, | |
] | |
if let uri = barcodeUri { payload["barcode_uri"] = uri } | |
if let manualInputCode = manualInputCode { payload["manual_input_code"] = manualInputCode } |
Copilot uses AI. Check for mistakes.
"auth_session": authSession, | ||
] | ||
if let uri = barcodeUri { payload["barcode_uri"] = uri } | ||
if let manualInoutcode = manualInoutcode { payload["manual_input_code"] = manualInoutcode } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name "manualInoutcode" should be "manualInputCode" for consistency.
if let manualInoutcode = manualInoutcode { payload["manual_input_code"] = manualInoutcode } | |
func totpPushEnrollmentChallengeResponse(id: String, authSession: String, barcodeUri: String? = nil, manualInputCode: String? = nil) -> RequestResponse { | |
var payload: [String: Any] = [ | |
"id": id, | |
"auth_session": authSession, | |
] | |
if let uri = barcodeUri { payload["barcode_uri"] = uri } | |
if let manualInputCode = manualInputCode { payload["manual_input_code"] = manualInputCode } |
Copilot uses AI. Check for mistakes.
Auth0/MyAccount/AuthenticationMethods/MyAccountAuthenticationMethods.swift
Outdated
Show resolved
Hide resolved
authMethods.confirmTOTPEnrolment(id: AuthenticationMethodId, | ||
authSession: AuthSession, | ||
otpCode: OTPCode).start { result in | ||
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's commented-out test code that appears to be incomplete or incorrect. This should either be completed or removed to maintain code cleanliness.
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp")) |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this expect commented out ? Is this giving the wrong result ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert the errors in the UTs and their corresponding messages
@@ -76,4 +75,204 @@ struct Auth0MyAccountAuthenticationMethods: MyAccountAuthenticationMethods { | |||
} | |||
#endif | |||
|
|||
func enrolRecoveryCode() -> Request<RecoveryCodeChallenge, MyAccountError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: it should be enrollRecoveryCode
telemetry: telemetry) | ||
} | ||
|
||
func enrollPhone(phoneNumber: String, preferredAuthenticationMethod: String) -> Request<PhoneEmailChallenge, MyAccountError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't preferredAuthenticationMethod an optional parameter ?
telemetry: telemetry) | ||
} | ||
|
||
func confirmTOTPEnrolment(id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: confirmTOTPEnrollment
telemetry: telemetry) | ||
} | ||
|
||
func confirmEmailEnrolment(id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: confirmEmailEnrollment
telemetry: telemetry) | ||
} | ||
|
||
func confirmPushNotificationEnrolment(id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: confirmPushNotificationEnrollment
/// } | ||
/// ``` | ||
/// | ||
/// - Returns: A request fetches factors enabled for the Auth0 tenant and available for enrollment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// - Returns: A request fetches factors enabled for the Auth0 tenant and available for enrollment | |
/// - Returns: Request to fetch factors enabled for the Auth0 tenant and available for enrollment |
Auth0/MyAccount/AuthenticationMethods/MyAccountAuthenticationMethods.swift
Outdated
Show resolved
Hide resolved
authMethods.confirmTOTPEnrolment(id: AuthenticationMethodId, | ||
authSession: AuthSession, | ||
otpCode: OTPCode).start { result in | ||
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this expect commented out ? Is this giving the wrong result ?
authMethods.confirmEmailEnrolment(id: AuthenticationMethodId, | ||
authSession: AuthSession, | ||
otpCode: OTPCode).start { result in | ||
expect(result).to(haveAuthenticationMethod(id: AuthenticationMethodId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for the type also in this case
authMethods.confirmTOTPEnrolment(id: AuthenticationMethodId, | ||
authSession: AuthSession, | ||
otpCode: OTPCode).start { result in | ||
expect(result).to(beUnsuccessful()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert for the error and the error message thrown for failure cases
📋 Changes
This PR covers the My Account Auth APIs EA release
EA release covers
📎 References
🎯 Testing
Enabled MFA in the tenant
Manual testing performed of all the apis