File: well_known.py

package info (click to toggle)
python-authlib 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,020 kB
  • sloc: python: 26,969; makefile: 53; sh: 14
file content (17 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from authlib.common.urls import urlparse


def get_well_known_url(issuer, external=False):
    """Get well-known URI with issuer via Section 4.1.

    :param issuer: URL of the issuer
    :param external: return full external url or not
    :return: URL
    """
    # https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest
    if external:
        return issuer.rstrip("/") + "/.well-known/openid-configuration"

    parsed = urlparse.urlparse(issuer)
    path = parsed.path
    return path.rstrip("/") + "/.well-known/openid-configuration"