Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
auth_scheme.py35 linesDownload Raw Back to msal
1try:2    from urllib.parse import urlparse3except ImportError:  # Fall back to Python 24    from urlparse import urlparse5 6# We may support more auth schemes in the future7class PopAuthScheme(object):8    HTTP_GET = "GET"9    HTTP_POST = "POST"10    HTTP_PUT = "PUT"11    HTTP_DELETE = "DELETE"12    HTTP_PATCH = "PATCH"13    _HTTP_METHODS = (HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_PATCH)14    # Internal design: https://identitydivision.visualstudio.com/DevEx/_git/AuthLibrariesApiReview?path=/PoPTokensProtocol/PopTokensProtocol.md15    def __init__(self, http_method=None, url=None, nonce=None):16        """Create an auth scheme which is needed to obtain a Proof-of-Possession token.17 18        :param str http_method:19            Its value is an uppercase http verb, such as "GET" and "POST".20        :param str url:21            The url to be signed.22        :param str nonce:23            The nonce came from resource's challenge.24        """25        if not (http_method and url and nonce):26            # In the future, we may also support accepting an http_response as input27            raise ValueError("All http_method, url and nonce are required parameters")28        if http_method not in self._HTTP_METHODS:29            raise ValueError("http_method must be uppercase, according to "30                "https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3")31        self._http_method = http_method32        self._url = urlparse(url)33        self._nonce = nonce34 35 
codekingpro/portable-devtools · Team Ai