A modular Flask base for User Access Management with MariaDB, Valkey, and Google OAuth
Project description
AnyAccess
A modular Flask backend for User Access Management. This package provides a pre-configured architecture using MariaDB for data, Valkey (Redis) for session management, and Google OAuth2 for authentication.
🛠 Prerequisites
For fedora-minimal, Ensure the system can handle mariadb:
sudo dnf install python3 mariadb-connector-c
⚙️ Configuration (.env)
Create a .env file in your project root:
# Database & Cache
MARIA_KEY=mysql://user:password@localhost/dbname
VALKEY_HOST=localhost
# Flask Security
FLASK_SECRET_KEY=your_secure_random_string
GLOBAL_SESSION_VERSION=1
# Google OAuth Credentials
GOOGLE_CLIENT_ID=your_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your_secret_key
CURRENT_URL=http://localhost:5000
GOOGLE_RETURN_FRONTEND=http://localhost:3000
# CORS Settings
ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000,http://192.168.128.35:3000,https://anyreact.khazu.net
🚀 Implementation Guide
A typical implementation involves two main files using the anyflask package.
- init.py This file initializes the core Flask application and its services.
from flask import Flask, session
from anyaccess import AnyInit as AI
app = Flask(__name__)
# Modular Service Initialization
AI.initCORS(app)
AI.initValkey(app)
AI.initMariaDB(app)
AI.initAPILogin(app)
@app.before_request
def check_session_version():
if session.get('ver') != AI.SESSION_VERSION:
session.clear()
session['ver'] = AI.SESSION_VERSION
def anyaccess_initcall():
# Optional hook for custom initialization logic
# will trigger when first user is created
return True
- main.py This file handles the API routing and serves the application.
from flask_restful import Api, Resource, reqparse
from init import app
from anyaccess import Account, Journal, AccountType, GoogleAuth, Authenticate
# Custom local resource example
class Test(Resource):
test_data = reqparse.RequestParser()
test_data.add_argument('test', required=True)
def get(self):
return {'status':'success'}
# API Registration
api = Api(app)
api.add_resource(Account, '/api/access/user')
api.add_resource(Journal, '/api/access/logs')
api.add_resource(AccountType, '/api/access/usertype')
api.add_resource(Authenticate, '/api/access/authenticate')
api.add_resource(GoogleAuth, '/api/access/google')
api.add_resource(Test, '/api/access/')
def serve_app():
return app
🔐 Authentication Flow
First User: The first user registered via /api/access/user POST MUST be a superuser. This triggers the automatic initialization of the UserType table.
Google Login: Users can authenticate via Google. Accounts are automatically created with a google- prefix using the Google sub ID.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anyaccess-0.1.11.tar.gz.
File metadata
- Download URL: anyaccess-0.1.11.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c85835a93aef26532efc2b1346748630527ff86537cfa15234ac3b748df014c
|
|
| MD5 |
ba9c6d76f18d18755a0f2319af668e0b
|
|
| BLAKE2b-256 |
c7309d99a2c2b1752805ea606747fd413b9068b366cee77621c338493a2746ba
|
File details
Details for the file anyaccess-0.1.11-py3-none-any.whl.
File metadata
- Download URL: anyaccess-0.1.11-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61bf6122e479469b9bb8cf7f38834aca7b2f254375e7c975eca89222789ed403
|
|
| MD5 |
3ff9efb8aeb49a4eed97d0b69f611dd9
|
|
| BLAKE2b-256 |
95cd94c9c86bb65fdf473410df5dccc623d7abee8711fea18af52d7b4d6e459a
|