Auth Server implements Json Web Token (JWT) based authentication using FastAPI as it's framework. The testing and Docker build process is built in, it's very easy to deploy it to any host that supports Docker.
docker build -t auth_server:latest .Replace <your-secret-a/b> with a your secret strings
docker run --name auth_server \
-d \
-p 3000:80 \
-e ACCESS_TOKEN_SECRET=<your-secret-a> \
-e REFRESH_TOKEN_SECRET=<your-secret-b> \
-e ACCESS_TOKEN_EXPIRY=<int minutes (default=15)> \
-e REFRESH_TOKEN_EXPIRY=<int minutes (default=180)> \
--restart always \
auth_serverdocker run --name auth_server ^
-d ^
-p 3000:80 ^
-e ACCESS_TOKEN_SECRET=<your-secret-a> ^
-e REFRESH_TOKEN_SECRET=<your-secret-b> ^
-e ACCESS_TOKEN_EXPIRY=<int minutes (default=15)> ^
-e REFRESH_TOKEN_EXPIRY=<int minutes (default=180)> ^
--restart always ^
auth_serverPlease refer to the documentation at /docs or /redoc for API endpoint details
- POST /admin_token/ Allow admin to login via webform and obtain an access token for this server
- POST /token/ Generate access_token and refresh_token for user
- POST /refresh/ Renew access_token using a valid refresh_token
- GET /user/ Retrieve a user using email
- GET /users/ Retrieve all users
- POST /user/ Create a new user (Authorisation as Admin required)
- PUT /user/ Update user attributes (Authorisation as Admin required)
- DELETE /user/ Delete a user (Authorisation as Admin required)
There is only one table in the database which is mapped to the User model below:
class User(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
email: EmailStr = Field(sa_column=Column("email", String, unique=True))
hashed_password: str
refresh_token: str | None = Field(default=None)
is_admin: bool = FalseA default admin user admin@example.com with password admin is built in. Please update it to something more secure immediately following the initialisation.