Skip to content

sanand0/jinjaauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Jinja Auth

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.

Conversion

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.css with {{ bootstrap5_css_url }}
  • Replaces https://cdn.jsdelivr.net/npm/bootstrap@5.*?/dist/js/bootstrap.bundle.min.js with {{ bootstrap5_js_url }}
  • Replaces src="script.js" with {{ script_js_url }}

Server

  1. Create OAuth credentials at Google Cloud Console

    • Set authorized redirect URI to http://localhost:8000/googleauth/
    • If you're deploying at https://yourdomain.com/, add https://yourdomain.com/googleauth/
  2. In the folder where you want to serve files, create a .env file with the following variables. (Or set them as environment variables.) This is typically done using CI/CD pipelines. You can also specify a .auth with 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
  3. Run the server:

    uv run https://raw.githubusercontent.com/sanand0/jinjaauth/refs/heads/main/app.py

This app.py is based on staticauth but

  1. Renders .jinja2 files as Jinja2 templates, passing the conversion variables
  2. Wildcard email IDs are not allowed in .auth / AUTH

About

Convert static files to Jinja templates and serve with restrictive auth

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages