feat: auto log in feature
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
cellarspoon 2022-01-10 09:09:33 +01:00
parent d8d0504570
commit e347b1eed1
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
3 changed files with 9 additions and 0 deletions

View File

@ -8,3 +8,4 @@ KEYCLOAK_REALM=lumbung-space
REDIS_DB=0
REDIS_HOST=localhost
REDIS_PORT=6379
AUTOMATICALLY_LOG_IN=False

View File

@ -38,3 +38,6 @@ elif LOG_LEVEL == "debug":
APP_LOG_LEVEL = logging.DEBUG
else:
APP_LOG_LEVEL = logging.INFO
# Automatically log folks in or show the default log in page?
AUTOMATICALLY_LOG_IN = environ.get("AUTOMATICALLY_LOG_IN", False)

View File

@ -11,6 +11,11 @@ router = APIRouter()
@router.get("/login")
async def login(request: Request):
from keycloak_collective_portal.config import AUTOMATICALLY_LOG_IN
if AUTOMATICALLY_LOG_IN:
return RedirectResponse(request.url_for("login_keycloak"))
return request.app.state.templates.TemplateResponse(
"login.html", context={"request": request}
)