def init_auth(): ok = auth.get_auth_backend().authenticate() if cfg.has_option('auth', 'require_authentication'): require_auth = cfg.getboolean('auth', 'require_authentication') else: require_auth = True if not ok and require_auth: raise AuthorizationError("Authentication failed. Authentication " "is required to use this service.")
def require_admin(self): """Ensure the request is authorized to act as an administrator. Raises an ``AuthorizationError`` on failure, instead of returning False. This is a convienence wrapper around ``have_admin``, and should not be overwritten by subclasses. """ if not self.have_admin(): raise AuthorizationError("This operation is administrator-only.")
def init_auth(): """Process authentication. This invokes the auth backend. If HIL is configured to *require* authentication, and authentication fails, it raises an AuthorizationError. """ ok = auth.get_auth_backend().authenticate() if cfg.has_option('auth', 'require_authentication'): require_auth = cfg.getboolean('auth', 'require_authentication') else: require_auth = True if not ok and require_auth: raise AuthorizationError("Authentication failed. Authentication " "is required to use this service.")
def require_project_access(self, project): """Like ``require_admin()``, but wraps ``have_project_access()``.""" if not self.have_project_access(project): raise AuthorizationError( "You do not have access to the required project.")