This app converts static HTML files into Jinja templates that can only be accessed via Google auth by specific users. This improves compliance with security requirements.
Using uv, run:
uv run https://raw.githubusercontent.com/sanand0/jinjaauth/refs/heads/main/convert.py [FOLDER]If the folder has an index.html, it renames it to index.jinja2 and, inside the file:
- Replaces
https://cdn.jsdelivr.net/npm/bootstrap@5.*?/dist/css/bootstrap.min.csswith{{ bootstrap5_css_url }} - Replaces
https://cdn.jsdelivr.net/npm/bootstrap@5.*?/dist/js/bootstrap.bundle.min.jswith{{ bootstrap5_js_url }} - Replaces
src="script.js"with{{ script_js_url }}
-
Create OAuth credentials at Google Cloud Console
- Set authorized redirect URI to
http://localhost:8000/googleauth/ - If you're deploying at
https://yourdomain.com/, addhttps://yourdomain.com/googleauth/
- Set authorized redirect URI to
-
In the folder where you want to serve files, create a
.envfile with the following variables. (Or set them as environment variables.) This is typically done using CI/CD pipelines. You can also specify a.authwith 1 line per email.GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret REDIRECT_URI=http://localhost:8000/googleauth/ PORT=8000 # Optional, defaults to 8000 AUTH=user1@example.com,user2@example.com
-
Run the server:
uv run https://raw.githubusercontent.com/sanand0/jinjaauth/refs/heads/main/app.py
This app.py is based on staticauth but
- Renders
.jinja2files as Jinja2 templates, passing the conversion variables - Wildcard email IDs are not allowed in .auth / AUTH