Files
claudeandClaude Opus 5.5 b8978221a3 Option to turn off local login (FUNKWHALE_OIDC_LOCAL_LOGIN)
With it false, a middleware rejects password login, sign-up and password
reset/change in the API, allauth's pages and the Django admin, and the
web app shows only the provider button. /login and /signup go straight
to the provider, and the post-login redirect never points back at them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 15:41:28 -05:00

47 lines
1.9 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Configuration, read from FUNKWHALE_OIDC_* environment variables."""
import functools
import environ
PREFIX = "FUNKWHALE_OIDC_"
@functools.cache
def get():
env = environ.Env()
def e(name, default=None, cast=env.str):
return cast(PREFIX + name, default=default)
return {
# Issuer URL; /.well-known/openid-configuration is appended.
"server_url": e("SERVER_URL", ""),
"client_id": e("CLIENT_ID", ""),
"client_secret": e("CLIENT_SECRET", ""),
# Part of the callback URL: /accounts/oidc/<provider_id>/login/callback/
"provider_id": e("PROVIDER_ID", "oidc"),
# Shown on the login button.
"name": e("NAME", "Single sign-on"),
"scopes": e("SCOPES", ["openid", "profile", "email"], env.list),
"pkce": e("PKCE", True, env.bool),
# Claim used as the Funkwhale username (and federation handle).
"username_claim": e("USERNAME_CLAIM", "preferred_username"),
# Create accounts for new provider users even when the instance's
# own sign-up form is closed. The provider decides who gets in.
"signup": e("SIGNUP", True, env.bool),
# Log a provider user into the existing local account with the same
# (provider-verified) e-mail. Only enable for a provider you trust
# to verify e-mail addresses.
"link_by_email": e("LINK_BY_EMAIL", False, env.bool),
# false: no password login, sign-up or password reset; the provider
# is the only way in. Recovery: funkwhale-manage in the API pod.
"local_login": e("LOCAL_LOGIN", True, env.bool),
# Superuser on every login if the username is listed, or if the
# groups claim contains one of the groups. Never revoked here.
"admin_users": e("ADMIN_USERS", [], env.list),
"admin_groups": e("ADMIN_GROUPS", [], env.list),
"groups_claim": e("GROUPS_CLAIM", "groups"),
}