No project description provided
Project description
Fastbase
DEV MESSAGE: Fastbase is currently still in development and in its current state is unfit for production. Check back again for updates.
Role-based Access Contral (RBAC) via Firebase idtoken authententication using FastAPI and SQLModel.
Documentation: https://enchance.github.io/fastbase/class/fastbase/
Installation
pip install fastbase
or
poetry add fastbase
Overview
Fastbase assumes a headless setup using a frontend such as React, Angular, etc.
- API Endpoints: Managed by FastAPI
- Authentication: Managed by Firebase Auth
- Authorization: Managed by Fastbase
- Database ORM: SQLModel
Fastbase process
- Authentication happens in the frontend (JS) using the official Firebase JS package. An
idtokenwill be generated if successful. - Insert this token in your
Authorizationheader (Bearer <idtoken>) when hitting restricted APIs. - Upon reaching the server the
idtokenis verified.
Endpoints
To follow
Dependencies
To follow
Sample Code
models.py
Your required User model. Optional models include TaxonomyMod and OptionMod which should be extended if you want
to use them. Add any additional fields you need.
from fastbase.models import UserMod, TaxonomyMod, OptionMod
# Required
class User(UserMod, table=True):
__tablename__ = 'auth_user'
# Add any fields and methods you need
# Optional
class Taxonomy(TaxonomyMod, table=True):
__tablename__ = 'app_taxonomy'
# Add any fields and methods you need
# Optional
class Option(OptionMod, table=True):
__tablename__ = 'app_option'
# Add any fields and methods you need
main.py
Initialize Fastbase
from sqlalchemy.ext.asyncio import create_async_engine
from fastapi import FastAPI
from fastbase import Fastbase
from contextlib import asynccontextmanager
from .models import User
# .env file
DATABASE_URL = 'postgresql+asyncpg://user:password@localhost:5432/dbname'
# DB engine
engine = create_async_engine(DATABASE_URL, echo=True, pool_size=10)
@asynccontextmanager
async def lifespan(_: FastAPI):
"""Insert in lifespan events on start: https://fastapi.tiangolo.com/advanced/events/"""
fbase = Fastbase()
fbase.initialize(engine=engine, user_model=User)
print('RUNNING')
yield
print('STOPPED')
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 fastbase-0.4.0.tar.gz.
File metadata
- Download URL: fastbase-0.4.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/5.15.0-91-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8ca010947613bda21d10fde68a1b4916b421d137b4d36a8133677cb180660b9
|
|
| MD5 |
0753af0083f32876e9dab98caccbbde1
|
|
| BLAKE2b-256 |
4007c62fe6c949b60dc111779a33f3d3cfbb2aec6ad06dfb9e42c6a2d624cb5d
|
File details
Details for the file fastbase-0.4.0-py3-none-any.whl.
File metadata
- Download URL: fastbase-0.4.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/5.15.0-91-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7208cc24cfc80a0cc2bd140ec8a00ed705f2db2497ab75e62301c4ef4775e54b
|
|
| MD5 |
6b4766cd5f800934a18d5b616c076777
|
|
| BLAKE2b-256 |
849608c2fb90a2df83ac388c20bebcd9baf9ca31fb7017458e2dd97f9f058042
|