Implement comprehensive authentication system with support for Basic Auth, Flask-Login, and OAuth2 providers. Features: - Pluggable architecture via factory pattern - Multiple authentication providers: * None: No authentication (development/testing) * Basic Auth: HTTP Basic with bcrypt support * Flask-Login: Session-based with multiple users * OAuth2: Google, GitHub, GitLab, and generic providers - Decorator-based route protection (@auth.require_auth) - User authorization by domain or email (OAuth) - bcrypt password hashing support - Comprehensive documentation and examples Components: - libtisbackup/auth/__init__.py: Factory function and exports - libtisbackup/auth/base.py: Base provider interface - libtisbackup/auth/basic_auth.py: HTTP Basic Auth implementation - libtisbackup/auth/flask_login_auth.py: Flask-Login implementation - libtisbackup/auth/oauth_auth.py: OAuth2 implementation - libtisbackup/auth/example_integration.py: Integration examples - libtisbackup/auth/README.md: API reference and examples Documentation: - AUTHENTICATION.md: Complete authentication guide * Setup instructions for each provider * Configuration examples * Security best practices * Troubleshooting guide * Migration guide - samples/auth-config-examples.ini: Configuration templates Dependencies: - Add optional dependencies in pyproject.toml: * auth-basic: bcrypt>=4.0.0 * auth-login: flask-login>=0.6.0, bcrypt>=4.0.0 * auth-oauth: authlib>=1.3.0, requests>=2.32.0 * auth-all: All auth providers Installation: ```bash # Install specific provider uv sync --extra auth-basic # Install all providers uv sync --extra auth-all ``` Usage: ```python from libtisbackup.auth import get_auth_provider # Initialize auth = get_auth_provider("basic", { "username": "admin", "password": "$2b$12$...", "use_bcrypt": True }) auth.init_app(app) # Protect routes @app.route("/") @auth.require_auth def index(): user = auth.get_current_user() return f"Hello {user['username']}" ``` Security features: - bcrypt password hashing (work factor 12) - OAuth domain/user restrictions - Session-based authentication - Clear separation of concerns - Environment variable support for secrets OAuth providers supported: - Google (OpenID Connect) - GitHub - GitLab - Generic OAuth2 provider Breaking change: None - new feature, backward compatible Users can continue without authentication (type=none) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
1.0 KiB
TOML
40 lines
1.0 KiB
TOML
[project]
|
|
name = "TISbackup"
|
|
version = "1.8.0"
|
|
description = "Backup server side executed python scripts for managing linux and windows system and application data backups, developed by adminsys for adminsys"
|
|
readme = "README.md"
|
|
dependencies = [
|
|
"flask==3.1.0",
|
|
"huey==2.5.3",
|
|
"iniparse==0.5",
|
|
"paramiko==3.5.1",
|
|
"peewee==3.17.9",
|
|
"pexpect==4.9.0",
|
|
"redis==5.2.1",
|
|
"requests==2.32.3",
|
|
"ruff>=0.13.3",
|
|
"simplejson==3.20.1",
|
|
"six==1.17.0",
|
|
]
|
|
requires-python = ">=3.13"
|
|
|
|
[project.optional-dependencies]
|
|
# Authentication providers
|
|
auth-basic = ["bcrypt>=4.0.0"]
|
|
auth-login = ["flask-login>=0.6.0", "bcrypt>=4.0.0"]
|
|
auth-oauth = ["authlib>=1.3.0", "requests>=2.32.0"]
|
|
# Install all auth providers
|
|
auth-all = ["bcrypt>=4.0.0", "flask-login>=0.6.0", "authlib>=1.3.0", "requests>=2.32.0"]
|
|
|
|
[tool.black]
|
|
line-length = 140
|
|
|
|
|
|
[tool.ruff]
|
|
# Allow lines to be as long as 120.
|
|
line-length = 140
|
|
indent-width = 4
|
|
|
|
[tool.ruff.lint]
|
|
ignore = ["F401", "F403", "F405", "E402", "E701", "E722", "E741"]
|