code: def auth_required(decorated_fn=None, **role_rules):
      
      required_roles = []
      one_of_roles = []
      if not (decorated_fn and callable(decorated_fn)):
          if 'role' in role_rules and 'roles' in role_rules:
              raise RuntimeError('specify only one of `role` or `roles` kwargs')
          elif 'role' in role_rules:
              required_roles = [role_rules['role']]
          elif 'roles' in role_rules:
              required_roles = role_rules['roles']
  
          if 'one_of' in role_rules:
              one_of_roles = role_rules['one_of']
  
      def wrapper(fn):
          @wraps(fn)
          @_auth_required()
          @roles_required(*required_roles)
          @roles_accepted(*one_of_roles)
          def decorated(*args, **kwargs):
              return fn(*args, **kwargs)
          return decorated
  
      if decorated_fn and callable(decorated_fn):
          return wrapper(decorated_fn)
      return wrapper
docs: Decorator for requiring an authenticated user, optionally with roles.
  
      Roles are passed as keyword arguments, like so::
  
          @auth_required(role='REQUIRE_THIS_ONE_ROLE')
          @auth_required(roles=['REQUIRE', 'ALL', 'OF', 'THESE', 'ROLES'])
          @auth_required(one_of=['EITHER_THIS_ROLE', 'OR_THIS_ONE'])
  
      One of role or roles kwargs can also be combined with one_of::
  
          @auth_required(role='REQUIRED', one_of=['THIS', 'OR_THIS'])
  
      Aborts with ``HTTP 401: Unauthorized`` if no user is logged in, or
      ``HTTP 403: Forbidden`` if any of the specified role checks fail.