Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed May 20, 2024
1 parent 9ffd073 commit ced34a6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ MagicalAuth is a simple but magical authentication system for Python application

## Environment Variables

- `APP_NAME`: The name of the application. This will be used in the magic link email to the user.
- `ALLOWED_DOMAINS`: A comma-separated list of allowed email domains. If this is set, only users with email addresses from these domains will be allowed to register and login. If this is not set, all email domains will be allowed.
- `ENCRYPTION_SECRET`: The secret key used to encrypt and decrypt the magic link tokens. This should be a long random string.
- `MAGIC_LINK_URL`: The URL that the magic link will point to. This should be the URL of the application that will handle the magic link. It will send query parameters `email` and `token` to this URL that will be used on the `/login` endpoint to authenticate the user.
- `MAGICALAUTH_SERVER`: The URL of the MagicalAuth server. This should be the URL of the server that is running the MagicalAuth FastAPI service.
- `MAGIC_LINK_URL`: The URL that the magic link will point to. This should be the URL of the application that will handle the magic link. It will send query parameters `email` and `token` to this URL that will be used on the `MAGIC_LINK_URL` endpoint to authenticate the user.
- `SENDGRID_API_KEY`: The API key for SendGrid. This is used to send the magic link email to the user.
- `SENDGRID_FROM_EMAIL`: The email address that the magic link email will be sent from. This should be a verified email address in SendGrid.
- `REGISTRATION_WEBHOOK`: The URL that the registration webhook will be sent to. This should be the URL of the application that will handle the registration webhook. It will send a POST request with a JSON body containing the user's email address.
- `DATABASE_USER`: The username for the PostgreSQL database.
- `DATABASE_PASSWORD`: The password for the PostgreSQL database.
- `DATABASE_HOST`: The host for the PostgreSQL database.
- `DATABASE_PORT`: The port for the PostgreSQL database.
- `DATABASE_NAME`: The name of the PostgreSQL database.
- `LOGLEVEL`: The log level for the application. This should be one of `DEBUG`, `INFO`, `WARNING`, `ERROR`, or `CRITICAL`.

## Usage

```bash
docker-compose down && docker-compose pull && docker-compose up
```

Access the FastAPI documentation at `http://localhost:14374` .
Access the FastAPI documentation at `http://localhost:12437` .
Access the Streamlit UI at `http://localhost:8519` .

## UI Example

Expand Down
2 changes: 1 addition & 1 deletion Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os

app = FastAPI(
title="MagicalAuth",
title=os.environ.get("APP_NAME", "MagicalAuth"),
description="A magical authentication system.",
version="0.0.1",
docs_url="/",
Expand Down
2 changes: 1 addition & 1 deletion UI.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import streamlit as st
from components.Auth import get_user, log_out_button
import os

app_name = os.environ.get("APP_NAME", "Magical Auth")

Expand Down
17 changes: 12 additions & 5 deletions components/Auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import streamlit as st
from streamlit_js_eval import get_cookie, set_cookie
import qrcode
import pyotp
import io
import os
import requests
import time
import pyotp
import qrcode
import requests
import streamlit as st
from streamlit_js_eval import get_cookie, set_cookie

"""
Required environment variables:
- APP_NAME: Name of the application
- MAGICALAUTH_SERVER: URL of the MagicalAuth server
"""


def get_user():
Expand Down

0 comments on commit ced34a6

Please sign in to comment.