How to use the authlib.specs.oidc.id_token.IDTokenError function in Authlib

To help you get started, we’ve selected a few Authlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_iat(self):
        if 'iat' not in self.token:
            raise IDTokenError('iat is required')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_nonce(self, nonce):
        if 'nonce' not in self.token:
            raise IDTokenError('nonce is required')
        if nonce != self.nonce:
            raise IDTokenError('nonce is invalid')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_exp(self, now):
        if 'exp' not in self.token:
            raise IDTokenError('exp is required')
        if now and now > self.exp:
            raise IDTokenError('exp is expired')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def parse_id_token(id_token, key):
    """Parse an id_token text string into token dict.

    :param id_token: A JWS text that represent current id_token.
    :param key: A PEM key to parse the given id_token. This value can be:
                * a string text of PEM key
                * a dict/string of JWK
                * a set/list/tuple of JWK
    :return: (token, header)
    """
    header, payload, valid = jws.verify(id_token, key)
    if not valid:
        raise IDTokenError('Invalid signature')
    token = json.loads(payload.decode('utf-8'))
    return token, header
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_iss(self, issuer):
        if 'iss' not in self.token:
            raise IDTokenError('iss is required')
        if isinstance(issuer, (list, tuple)):
            if self.iss not in issuer:
                raise IDTokenError('iss is invalid')
        elif issuer is not None and self.iss != issuer:
            raise IDTokenError('iss is invalid')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_iss(self, issuer):
        if 'iss' not in self.token:
            raise IDTokenError('iss is required')
        if isinstance(issuer, (list, tuple)):
            if self.iss not in issuer:
                raise IDTokenError('iss is invalid')
        elif issuer is not None and self.iss != issuer:
            raise IDTokenError('iss is invalid')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_sub(self):
        if 'sub' not in self.token:
            raise IDTokenError('sub is required')
        if len(self.sub) > 255:
            raise IDTokenError('sub exceed 255 in length')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_exp(self, now):
        if 'exp' not in self.token:
            raise IDTokenError('exp is required')
        if now and now > self.exp:
            raise IDTokenError('exp is expired')
github lepture / authlib / authlib / specs / oidc / id_token.py View on Github external
def validate_azp(self, client_id):
        if self.azp or len(self.aud) > 1:
            if self.azp != client_id:
                raise IDTokenError('azp is not for this client')