fasthtml icon indicating copy to clipboard operation
fasthtml copied to clipboard

[FEATURE] OAuth Azure AD/Entra

Open urskog84 opened this issue 7 months ago • 0 comments

Hello

is it posible to add OAuth support for Azure AD or Microsoft Entra ID as it call nowadays.

i have ben playing around in the https://github.com/AnswerDotAI/fasthtml/blob/main/nbs/api/08_oauth.ipynb

adding somthing like tish

# %% ../nbs/api/08_oauth.ipynb
class AzureAppClient(_AppClient):
    "A `WebApplicationClient` for Microsoft Entra (Azure AD)"

    def __init__(
        self, client_id, client_secret, tenant_id, code=None, scope=None, **kwargs
    ):
        self.tenant_id = tenant_id
        self.base_url = (
            f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize"
        )
        self.token_url = (
            f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
        )
        self.info_url = "https://graph.microsoft.com/oidc/userinfo"

        # Microsoft kräver scope med fullständiga URI:er
        if not scope:
            scope = [
                "openid",
                "profile",
                "email",
                "https://graph.microsoft.com/User.Read",
            ]

        super().__init__(client_id, client_secret, code=code, scope=scope, **kwargs)

    @classmethod
    def from_file(cls, fname, code=None, scope=None, **kwargs):
        cred = Path(fname).read_json()
        return cls(
            cred["client_id"],
            client_secret=cred["client_secret"],
            tenant_id=cred["tenant_id"],
            code=code,
            scope=scope,
            **kwargs,
        )

i dont understand the structure of the auth file its so much @patch going on iam not 100% familr with this

urskog84 avatar Apr 20 '25 14:04 urskog84