Decorator ensures only superuser API keys can request this function.
518472
def superuser_api_key_required(f):
    """"""
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        api_key = current_api_key()
        g.api_key = api_key

        utils.jsonify_assert(
            api_key.superuser,
            'API key=%r must be a super user' % api_key.id,
            403)

        return f(*args, **kwargs)

    return wrapped
811008
def superuser_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME,
                       login_url='admin:login'):
    
    actual_decorator = user_passes_test(
        lambda u: u.is_active and u.is_superuser,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if view_func:
        return actual_decorator(view_func)
    return actual_decorator
987097
def login_not_required(func):
    

    @functools.wraps(func)
    def decorated_view(*args, **kwargs):
        return func(*args, **kwargs)

    return decorated_view
29831
def require_auth(function):
    
    @functools.wraps(function)
    def wrapper(self, *args, **kwargs):
        if not self.access_token():
            raise MissingAccessTokenError
        return function(self, *args, **kwargs)
    return wrapper
545965
def jwt_required(func):
    
    if inspect.isclass(func):
        apply_function_to_members(func, jwt_required)
        return func
    else:
        @functools.wraps(func)
        def deco(*a, **kw):
            if not "Authorization" in request.headers:
                abort(401, "Not Authorized")
            return func(*a, **kw)

        return deco
940393
def requires_auth(func):
    """"""
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        if self.token is None or self.token_expired:
            self.login()
        elif self.token_needs_refresh:
            self.refresh_token()
        return func(self, *args, **kwargs)
    return wrapper
174046
def credentials_required(view_func):
    
    @wraps(view_func, assigned=available_attrs(view_func))
    def decorator(request, *args, **kwargs):
        if settings.LOCALSHOP_USE_PROXIED_IP:
            try:
                ip_addr = request.META['HTTP_X_FORWARDED_FOR']
            except KeyError:
                return HttpResponseForbidden('No permission')
            else:
                # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs.
                # The client's IP will be the first one.
                ip_addr = ip_addr.split(",")[0].strip()
        else:
            ip_addr = request.META['REMOTE_ADDR']

        if CIDR.objects.has_access(ip_addr, with_credentials=False):
            return view_func(request, *args, **kwargs)

        if not CIDR.objects.has_access(ip_addr, with_credentials=True):
            return HttpResponseForbidden('No permission')

        # Just return the original view because already logged in
        if request.user.is_authenticated():
            return view_func(request, *args, **kwargs)

        user = authenticate_user(request)
        if user is not None:
            login(request, user)
            return view_func(request, *args, **kwargs)

        return HttpResponseUnauthorized(content='Authorization Required')
    return decorator
860352
def login_required(fn):
    
    @wraps(fn)
    async def wrapped(*args, **kwargs):
        request = args[-1]
        if not isinstance(request, web.BaseRequest):
            msg = ("Incorrect decorator usage. "
                   "Expecting `def handler(request)` "
                   "or `def handler(self, request)`.")
            raise RuntimeError(msg)

        await check_authorized(request)
        return await fn(*args, **kwargs)

    warnings.warn("login_required decorator is deprecated, "
                  "use check_authorized instead",
                  DeprecationWarning)
    return wrapped
401012
def validate_key(func):
    

    @wraps(func)
    def wrapper(self, key, *args, **kwargs):
        if posixpath.sep in key:
            raise ValueError('Keys cannot contains slashes')

        return func(self, key, *args, **kwargs)

    return wrapper
394506
def requires_user(fn):
        
        @functools.wraps(fn)
        def wrap(*args, **kwargs):

            subject = WebYosai.get_current_subject()

            if subject.identifiers is None:
                msg = ("Attempting to perform a user-only operation.  The "
                       "current Subject is NOT a user (they haven't been "
                       "authenticated or remembered from a previous login). "
                       "ACCESS DENIED.")
                raise WebYosai.get_current_webregistry().raise_unauthorized(msg)
            return fn(*args, **kwargs)
        return wrap
959334
function(apiKey) {
  return function(path, data, done) {
    var url = apiBase + path + '?' + querystring.stringify(_.extend({ 'key': apiKey }, data));
    request.get(url, globalResponseHandler({ url: url }, done));
  };
}
819553
def allowed(self, method, _dict, allow):
        
        for key in _dict.keys():
            if key not in allow:
                raise LunrError("'%s' is not an argument for method '%s'"
                                % (key, method))
1030058
def onlyOnce(fn):
    ''
    def wrap(*args, **kwargs):
        if hasattr(fn, 'called'):
            return
        fn.called = 1
        return fn(*args, **kwargs)
    util.mergeFunctionMetadata(fn, wrap)
    return wrap
866122
def requires_public_key(func):
    

    def func_wrapper(self, *args, **kwargs):
        if hasattr(self, "public_key"):
            func(self, *args, **kwargs)
        else:
            self.generate_public_key()
            func(self, *args, **kwargs)

    return func_wrapper
1243467
def anonymous_required(function):
    """"""

    def wrapper(*args, **kwargs):
        if args[0].user.is_authenticated():
            url = settings.ANONYMOUS_REQUIRED_REDIRECT_URL
            return HttpResponseRedirect(reverse(url))
        return function(*args, **kwargs)

    return wrapper
845784
def sudo_required(func):
    
    @wraps(func)
    def inner(request, *args, **kwargs):
        if not request.is_sudo():
            return redirect_to_sudo(request.get_full_path())
        return func(request, *args, **kwargs)
    return inner
154058
def http_basic_auth_superuser_required(func=None):
    """"""

    wrapper = auth.set_authentication_predicate(http_basic_auth_check_user, [auth.user_is_superuser])

    # If @http_basic_auth_superuser_required() is used (with parenthesis)
    if func is None:
        return wrapper

    # If @http_basic_auth_superuser_required is used without parenthesis
    return wrapper(func)