當前位置: 首頁>>代碼示例>>Python>>正文


Python jwk.SYMKey方法代碼示例

本文整理匯總了Python中jwkest.jwk.SYMKey方法的典型用法代碼示例。如果您正苦於以下問題:Python jwk.SYMKey方法的具體用法?Python jwk.SYMKey怎麽用?Python jwk.SYMKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jwkest.jwk的用法示例。


在下文中一共展示了jwk.SYMKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_client_alg_keys

# 需要導入模塊: from jwkest import jwk [as 別名]
# 或者: from jwkest.jwk import SYMKey [as 別名]
def get_client_alg_keys(client):
    """
    Takes a client and returns the set of keys associated with it.
    Returns a list of keys.
    """
    if client.jwt_alg == 'RS256':
        keys = []
        for rsakey in RSAKey.objects.all():
            keys.append(jwk_RSAKey(key=importKey(rsakey.key), kid=rsakey.kid))
        if not keys:
            raise Exception('You must add at least one RSA Key.')
    elif client.jwt_alg == 'HS256':
        keys = [SYMKey(key=client.client_secret, alg=client.jwt_alg)]
    else:
        raise Exception('Unsupported key algorithm.')

    return keys 
開發者ID:juanifioren,項目名稱:django-oidc-provider,代碼行數:19,代碼來源:token.py

示例2: create_jwt

# 需要導入模塊: from jwkest import jwk [as 別名]
# 或者: from jwkest.jwk import SYMKey [as 別名]
def create_jwt(self, user):
        """
        Creates a signed (JWS) ID token.

        Returns:
            str: JWS
        """
        key = SYMKey(key=self.site.siteconfiguration.oauth_settings['SOCIAL_AUTH_EDX_OAUTH2_SECRET'])
        now = datetime.datetime.utcnow()
        expiration_datetime = now + datetime.timedelta(seconds=3600)
        issue_datetime = now
        payload = {
            'iss': self.site.siteconfiguration.lms_url_root,
            'administrator': False,
            'iat': timegm(issue_datetime.utctimetuple()),
            'sub': str(uuid.uuid4()),
            'preferred_username': user.username,
            'aud': self.site.siteconfiguration.oauth_settings['SOCIAL_AUTH_EDX_OAUTH2_KEY'],
            'exp': timegm(expiration_datetime.utctimetuple()),
        }
        access_token = JWS(payload, jwk=key, alg='HS512').sign_compact()
        return access_token 
開發者ID:edx,項目名稱:ecommerce,代碼行數:24,代碼來源:test_strategies.py

示例3: signed_id_token

# 需要導入模塊: from jwkest import jwk [as 別名]
# 或者: from jwkest.jwk import SYMKey [as 別名]
def signed_id_token(claims):
    id_token = IdToken(**claims)
    signing_key = SYMKey(alg='HS256', key=rndstr())
    jws = id_token.to_jwt(key=[signing_key], algorithm=signing_key.alg)
    return jws, signing_key 
開發者ID:zamzterz,項目名稱:Flask-pyoidc,代碼行數:7,代碼來源:util.py

示例4: signing_keys

# 需要導入模塊: from jwkest import jwk [as 別名]
# 或者: from jwkest.jwk import SYMKey [as 別名]
def signing_keys(self):
        if self.signing_alg == self.RS256:
            # TODO perform caching, OBVIOUS
            return load_jwks_from_url(self.jwks_uri)

        return [SYMKey(key=str(self.client_secret))] 
開發者ID:intelie,項目名稱:django-oidc-auth,代碼行數:8,代碼來源:models.py


注:本文中的jwkest.jwk.SYMKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。