The Stew Authentication Microservice is a robust, secure, and scalable solution designed to handle authentication for various applications. It employs modern security practices, including JWT (JSON Web Tokens) for maintaining session state and bcrypt for password hashing, ensuring secure and efficient authentication. This service is designed to be a starting point for secure authentication and can be extended and customized based on specific application requirements.
- See this documentation for more information about the features provided by the microservice.
- See this documentation for more information about the testing provided by the microservice.
Please update the instructions as necessary for the latest version.
docker pull ghcr.io/louissullivan4/stewauth:1.2.0
Create a .env file in the current directory and include the following variables:
- JWT_SECRET: A randomly generated JWT secret.
- PORT: The port number on which the service will run (default is 3005).
- MONGO_URI: The MongoDB URI. This can be a local MongoDB instance (mongodb://localhost:27017/DbName) or a remote database.
- CLEAR_DB: Set to true to delete the database on startup. CAUTION!
- DISABLE_RATE_LIMIT: Disables rate limiting, mainly used for testing purposes.
JWT_SECRET=your_random_secret
PORT=3005
MONGO_URI=mongodb://localhost:27017/YourDbName
CLEAR_DB=false
DISABLE_RATE_LIMIT=false
Run the Docker image with the following command, passing the .env file:
docker run --env-file .env -p 3005:3005 ghcr.io/louissullivan4/stewauth:1.2.0
Note: If using a local database, ensure that your Docker container has access to the MongoDB instance. Consider using Docker Compose for easier setup, or opt for a cloud-hosted database.
docker pull ghcr.io/louissullivan4/stewauth:1.2.0
docker pull mongo:4.4
docker network create stew-auth_default
docker run --name mongodb --network stew-auth_default -d mongo:4.4
docker exec -it mongodb mongo
use myDatabaseName
db.createUser({user: 'setUserName',pwd: 'setUserPassword',roles: [{ role: 'readWrite', db: 'myDatabaseName' }]})
db.auth('setUserName', 'setUserPassword')
MONGO_URI=mongodb://setUserName:setUserPassword@mongodb:27017/myDatabaseName
MONGO_URI=mongodb://setUserName:setUserPassword@mongodb:27017/myDatabaseName
Step 8: Run stew auth container with .env set to your new file and your network set to stew-auth_default
docker run --env-file .env --network stew-auth_default -p 3005:3005 ghcr.io/louissullivan4/stewauth:1.2.0
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Password123!"}'