Skip to content
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

[FEAT] Integrate Persona Authentication with User Management API #1138

Open
0x00whitecode opened this issue Feb 28, 2025 · 0 comments
Open

Comments

@0x00whitecode
Copy link

At present, the API offers fundamental user management functions but does not connect with Persona for identity verification. This improvement will guarantee that users are authenticated prior to executing essential tasks, such as account deletions or modifications. Incorporating Persona's authentication process will enhance security, minimize fraud, and simplify user onboarding.

Endpoints

Initiate Persona Verification

  • Method: POST
  • URL: /api/v1/users/{user_id}/persona/initiate
  • Description: Starts the Persona verification process for a user.

Check Persona Verification Status

  • Method: GET
  • URL: /api/v1/users/{user_id}/persona/status
  • Description: Retrieves the current Persona verification status of a user.

Requirements

Authentication:

  • Endpoints must be secured and accessible only to authenticated users.
  • Admins should be able to check verification statuses for users.

Input Validation:

  • Ensure valid user_id is provided in requests.
  • Validate response data from Persona API before storing it in the database.

Error Handling:

  • 401 UNAUTHORIZED: Missing or invalid authentication tokens.
  • 400 BAD REQUEST: Invalid input data (e.g., incorrect user ID format).
  • 404 NOT FOUND: User does not exist or has not initiated verification.
  • 500 INTERNAL SERVER ERROR: Issues with Persona API or internal errors.

Testing

Implement unit and integration tests to cover:

  • Successful initiation of Persona verification for a user.
  • Successful retrieval of a user’s verification status.
  • Unauthorized access attempts returning a 401 error.
  • Invalid input data returning a 400 error.
  • Attempts to check verification for a non-existent user returning a 404 error.

Documentation

  • Update API documentation to include details about these new endpoints.
  • Provide request and response examples, authentication requirements, and error handling guidelines.

Success Responses

Initiate Persona Verification (HTTP 200 OK)

{
  "status": "success",
  "status_code": 200,
  "message": "Persona verification initiated successfully",
  "data": {
    "user_id": "12345",
    "persona_session_id": "abc123xyz",
    "verification_status": "pending"
  }
}

Check Persona Verification Status (HTTP 200 OK)

{
  "status": "success",
  "status_code": 200,
  "message": "User verification status retrieved",
  "data": {
    "user_id": "12345",
    "verification_status": "approved",
    "updated_at": "2025-02-28T12:00:00Z"
  }
}

Error Responses

Code: 401 UNAUTHORIZED

{
  "status": "failure",
  "status_code": 401,
  "message": "Not authenticated"
}

Code: 400 BAD REQUEST

{
  "status": "failure",
  "status_code": 400,
  "message": "Invalid input data"
}

Code: 404 NOT FOUND

{
  "status": "failure",
  "status_code": 404,
  "message": "User not found"
}

Code: 500 INTERNAL SERVER ERROR

{
  "status": "error",
  "status_code": 500,
  "message": "An unexpected error occurred"
}
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

No branches or pull requests

1 participant