imperfectandcompany / Imperfect-Gamers-API

https:/api.imperfectgamers.org
0 stars 0 forks source link

Implement Secure Endpoint for Handling Steam Account Linking #1

Closed cheesea3 closed 1 month ago

cheesea3 commented 1 month ago

We need to establish a secure endpoint within the Imperfect Gamers API to handle the linking of Steam accounts received from the frontend. This endpoint will securely accept, validate, and store the Steam ID associated with a user's account, ensuring that it cannot be tampered with or spoofed.

Requirements

Justification

By setting up a secure backend endpoint, we protect the integrity of user data and prevent unauthorized manipulation of Steam IDs. This approach keeps our API endpoints hidden from the frontend, minimizing potential exposure and security risks.

Proposed Implementation Steps:

  1. Endpoint Setup: Create a new endpoint in the router configuration to handle POST requests at /user/linkSteam.
  2. Authentication: Verify the user's authentication token to ensure the request is legitimate.
  3. Data Validation: Check the format and integrity of the received Steam ID, ensuring it matches expected patterns and criteria.
  4. Database Interaction: If validation passes, update the user's profile in the database with the new Steam ID.
  5. Response Handling: Return success or error messages based on the operation outcome.
  6. Logging: Maintain logs for both successful and unsuccessful attempts, noting the user ID, timestamp, and any relevant details.

Security Considerations:

This endpoint will directly mirror the functionality seen in our settings management system on the main site: https://github.com/imperfectandcompany/Imperfect-Gamers-Site-Main/blob/main/backend/attachSteam.php, where Steam linking is handled efficiently and securely, providing a smooth user experience while maintaining robust security practices.