本文整理汇总了Python中openedx.core.djangoapps.oauth_dispatch.toggles.ENFORCE_JWT_SCOPES.is_enabled方法的典型用法代码示例。如果您正苦于以下问题:Python ENFORCE_JWT_SCOPES.is_enabled方法的具体用法?Python ENFORCE_JWT_SCOPES.is_enabled怎么用?Python ENFORCE_JWT_SCOPES.is_enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openedx.core.djangoapps.oauth_dispatch.toggles.ENFORCE_JWT_SCOPES
的用法示例。
在下文中一共展示了ENFORCE_JWT_SCOPES.is_enabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_use_asymmetric_key_value
# 需要导入模块: from openedx.core.djangoapps.oauth_dispatch.toggles import ENFORCE_JWT_SCOPES [as 别名]
# 或者: from openedx.core.djangoapps.oauth_dispatch.toggles.ENFORCE_JWT_SCOPES import is_enabled [as 别名]
def _get_use_asymmetric_key_value(is_restricted, use_asymmetric_key):
"""
Returns the value to use for use_asymmetric_key.
"""
# TODO: (ARCH-162)
# If JWT scope enforcement is enabled, we need to sign tokens
# given to restricted applications with a key that
# other IDAs do not have access to. This prevents restricted
# applications from getting access to API endpoints available
# on other IDAs which have not yet been protected with the
# scope-related DRF permission classes. Once all endpoints have
# been protected, we can enable all IDAs to use the same new
# (asymmetric) key.
if use_asymmetric_key is None:
use_asymmetric_key = ENFORCE_JWT_SCOPES.is_enabled() and is_restricted
return use_asymmetric_key
示例2: should_expire_access_token
# 需要导入模块: from openedx.core.djangoapps.oauth_dispatch.toggles import ENFORCE_JWT_SCOPES [as 别名]
# 或者: from openedx.core.djangoapps.oauth_dispatch.toggles.ENFORCE_JWT_SCOPES import is_enabled [as 别名]
def should_expire_access_token(cls, application):
set_token_expired = not ENFORCE_JWT_SCOPES.is_enabled()
jwt_not_requested = get_request_or_stub().POST.get('token_type', '').lower() != 'jwt'
restricted_application = cls.objects.filter(application=application).exists()
return restricted_application and (jwt_not_requested or set_token_expired)