Skip to content

Conversation

NandanPrabhu
Copy link
Contributor

@NandanPrabhu NandanPrabhu commented Jul 4, 2025

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

This PR covers the My Account Auth APIs EA release
EA release covers

  • GET all factors
  • GET all auth methods - auth methods covered are phone, TOTP, Push noitification, passkey, email, Recovery code
  • POST Start enrolment of auth factor
  • POST Confirm enrolment of auth factor
  • PATCH - update name and preferred authentication method of auth methods
  • DELETE - delete auth methods
  • GET - get auth methods using id

📎 References

🎯 Testing

Enabled MFA in the tenant
Manual testing performed of all the apis

@NandanPrabhu NandanPrabhu marked this pull request as ready for review August 1, 2025 07:48
@NandanPrabhu NandanPrabhu requested a review from a team as a code owner August 1, 2025 07:48
* master:
  Release 2.14.0 (#992)
  Added Custom Token Exchange (CTE) Support (#989)
  chore(ci): Remove Semgrep GHA Workflow (#991)
  Add DPoP support [SDK-5542] (#983)
  Bump aws-actions/configure-aws-credentials from 4.2.1 to 4.3.1 in /.github/actions/rl-scanner (#990)
@pmathew92 pmathew92 requested a review from Copilot August 14, 2025 06:15
Copy link

@Copilot Copilot AI left a 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.

case transports
case confirmed
case name
case preferredAuthenticationMethod = "preferrred_authentication_method"
Copy link
Preview

Copilot AI Aug 14, 2025

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').

Suggested change
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))
Copy link
Preview

Copilot AI Aug 14, 2025

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.

Suggested change
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 }
Copy link
Preview

Copilot AI Aug 14, 2025

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.

Suggested change
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 }
Copy link
Preview

Copilot AI Aug 14, 2025

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.

Suggested change
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.

authMethods.confirmTOTPEnrolment(id: AuthenticationMethodId,
authSession: AuthSession,
otpCode: OTPCode).start { result in
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp"))
Copy link
Preview

Copilot AI Aug 14, 2025

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.

Suggested change
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp"))

Copilot uses AI. Check for mistakes.

Copy link
Contributor

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 ?

Copy link
Contributor

@pmathew92 pmathew92 left a 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> {
Copy link
Contributor

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> {
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - 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

authMethods.confirmTOTPEnrolment(id: AuthenticationMethodId,
authSession: AuthSession,
otpCode: OTPCode).start { result in
// expect(result).to(haveauth(id: AuthenticationMethodId, type: "totp"))
Copy link
Contributor

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))
Copy link
Contributor

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())
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants