OIDC Discovery Service (services/oidc_discovery.py)

agents-universe · packages/api/src/api/services/oidc_discovery.py · python · Apache-2.0
auth, database, security, lang:python

Fetches and caches OpenID Connect configuration endpoints from an issuer URL. Use this to simplify OIDC provider integration and authentication.

# Source: https://github.com/agents-universe/agents-universe | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""OIDC Discovery — fetch and cache provider endpoints from .well-known/openid-configuration."""
from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

import httpx


@dataclass(frozen=True)
class OIDCEndpoints:
    authorization_endpoint: str
    token_endpoint: str
    userinfo_endpoint: str
    revocation_endpoint: Optional[str] = None
    end_session_endpoint: Optional[str] = None


_cache: dict[str, OIDCEndpoints] = {}


async def discover(issuer_url: str) -> OIDCEndpoints:
    """Fetch OIDC discovery document and return parse

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key