Implement user authentication and permissions
This commit is contained in:
parent
5e9d90ed0b
commit
ac8303378a
26 changed files with 1182 additions and 172 deletions
39
app/main.py
39
app/main.py
|
@ -1,19 +1,20 @@
|
|||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from fastapi import APIRouter, FastAPI
|
||||
from starlette.middleware.authentication import AuthenticationMiddleware
|
||||
|
||||
load_dotenv()
|
||||
|
||||
from app.routers import (
|
||||
auth_v1,
|
||||
chargepoint_v1,
|
||||
id_token_v1,
|
||||
me_v1,
|
||||
meter_value_v1,
|
||||
ocpp_v1,
|
||||
transaction_v1,
|
||||
user_v1
|
||||
)
|
||||
from app.util.websocket_auth_backend import BasicAuthBackend
|
||||
from app.security.websocket_auth_backend import BasicAuthBackend
|
||||
|
||||
def create_ocpp_app():
|
||||
app_ocpp = FastAPI(
|
||||
|
@ -24,30 +25,26 @@ def create_ocpp_app():
|
|||
|
||||
return app_ocpp
|
||||
|
||||
def custom_openapi():
|
||||
if app.openapi_schema:
|
||||
return app.openapi_schema
|
||||
openapi_schema = get_openapi(
|
||||
title="simple-ocpp-cs",
|
||||
version="0.1.0",
|
||||
summary="Simple implementation of a basic OCPP 2.0.1 compliant central system (backend) for EV charging stations",
|
||||
routes=app.routes,
|
||||
)
|
||||
app.openapi_schema = openapi_schema
|
||||
return app.openapi_schema
|
||||
|
||||
def create_app():
|
||||
app = FastAPI(
|
||||
title="simple-ocpp-cs",
|
||||
summary="Simple implementation of a basic OCPP 2.0.1 compliant central system (backend) for EV charging stations",
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
app.include_router(chargepoint_v1.router, prefix="/v1")
|
||||
app.include_router(id_token_v1.router, prefix="/v1")
|
||||
app.include_router(user_v1.router, prefix="/v1")
|
||||
app.include_router(meter_value_v1.router, prefix="/v1")
|
||||
app.include_router(transaction_v1.router, prefix="/v1")
|
||||
api_v1_router = APIRouter(
|
||||
prefix="/api/v1"
|
||||
)
|
||||
api_v1_router.include_router(auth_v1.router)
|
||||
api_v1_router.include_router(chargepoint_v1.router)
|
||||
api_v1_router.include_router(id_token_v1.router)
|
||||
api_v1_router.include_router(me_v1.router)
|
||||
api_v1_router.include_router(user_v1.router)
|
||||
api_v1_router.include_router(meter_value_v1.router)
|
||||
api_v1_router.include_router(transaction_v1.router)
|
||||
|
||||
app.include_router(api_v1_router)
|
||||
app.mount(path="/v1/ocpp", app=create_ocpp_app())
|
||||
app.openapi = custom_openapi
|
||||
|
||||
return app
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue