imperfectandcompany / Imperfect-Gamers-Site-Store

Our robust community site integrating Steam for enhanced user interactions and data management, powered by Remix with Tailwind CSS for optimistic, responsive UI. Features CI/CD with GitHub Actions and Docker for seamless deployment and maintenance.
https://store.imperfectgamers.org/
Other
0 stars 0 forks source link

Resolve Auth Issue with Tebex API and Secure Runtime Environment Configuration #6

Closed cheesea3 closed 4 months ago

cheesea3 commented 4 months ago

Overview

This PR addresses two main issues identified during our deployment process: a Basic Auth issue with the Tebex API and the secure handling of environment variables in our Docker container setup.

Auth Issue with Tebex API

While initially suspected to be a client IP forwarding issue, the problem with Tebex basket creation was ultimately due to a misconfiguration in Basic Auth. Notably, the issue was not present locally, which led to an investigation into the discrepancies between local and production environments.

Root Cause and Resolution

The reason it worked locally without explicit Basic Auth headers is likely because of the stored credentials in the local environment or within the development tools like Postman, which automatically handle Basic Auth for known endpoints. When the server runs locally, it could also be using previously established sessions or tokens that bypass the need for repeated Basic Auth.

To ensure consistent authentication with the Tebex API across all environments, we now explicitly set Basic Auth headers in our API requests. This guarantees that the authentication process is clear and controlled directly within our application code.

Secure Environment Configuration

We have also refined the process for handling environment variables. Previously, we created a .env file during our CI/CD workflow, which is unsafe for a public repository due to the risk of leaking sensitive information.

Implemented Solution

The solution was to eliminate the generation of a .env file. Instead, we're passing the environment variables directly at runtime using the -e flag in Docker. This ensures that our secrets are injected into the container without being exposed in the image or the repository.

Changes Made

Testing

Conclusion

The changes made here not only resolve the immediate issue with the Tebex API but also strengthen our overall security practices, particularly with regard to how we manage sensitive information in a public repository setting.