Skip to content

_oauth

OAuthSettings

Bases: BaseSettings

Minimal set of configurations needed for operating on the database (e.g for schema migrations).

Source code in fractal_server/config/_oauth.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class OAuthSettings(BaseSettings):
    """
    Minimal set of configurations needed for operating on the database (e.g
    for schema migrations).
    """

    model_config = SettingsConfigDict(**SETTINGS_CONFIG_DICT)

    OAUTH_CLIENT_NAME: (
        Annotated[
            NonEmptyStr,
            StringConstraints(to_lower=True),
        ]
        | None
    ) = None
    """
    The name of the client.
    """
    OAUTH_CLIENT_ID: SecretStr | None = None
    """
    ID of client.
    """
    OAUTH_CLIENT_SECRET: SecretStr | None = None
    """
    Secret to authorise against the identity provider.
    """
    OAUTH_OIDC_CONFIG_ENDPOINT: str | None = None
    """
    OpenID configuration endpoint, for autodiscovery of relevant endpoints.
    """
    OAUTH_REDIRECT_URL: str | None = None
    """
    String to be used as `redirect_url` argument in
    `fastapi_users.get_oauth_router`, and then in
    `httpx_oauth.integrations.fastapi.OAuth2AuthorizeCallback`
    """

    @model_validator(mode="after")
    def check_configuration(self: Self) -> Self:
        if (
            self.OAUTH_CLIENT_NAME not in ["google", "github", None]
            and self.OAUTH_OIDC_CONFIG_ENDPOINT is None
        ):
            raise ValueError(
                f"{self.OAUTH_OIDC_CONFIG_ENDPOINT=} but "
                f"{self.OAUTH_CLIENT_NAME=}"
            )
        return self

    @property
    def is_set(self) -> bool:
        return None not in (
            self.OAUTH_CLIENT_NAME,
            self.OAUTH_CLIENT_ID,
            self.OAUTH_CLIENT_SECRET,
        )

OAUTH_CLIENT_ID = None class-attribute instance-attribute

ID of client.

OAUTH_CLIENT_NAME = None class-attribute instance-attribute

The name of the client.

OAUTH_CLIENT_SECRET = None class-attribute instance-attribute

Secret to authorise against the identity provider.

OAUTH_OIDC_CONFIG_ENDPOINT = None class-attribute instance-attribute

OpenID configuration endpoint, for autodiscovery of relevant endpoints.

OAUTH_REDIRECT_URL = None class-attribute instance-attribute

String to be used as redirect_url argument in fastapi_users.get_oauth_router, and then in httpx_oauth.integrations.fastapi.OAuth2AuthorizeCallback