Module sanic_security.exceptions
Classes
class AccountError (message, code)
-
Expand source code
class AccountError(SecurityError): """Base account error that all other account errors derive from.""" def __init__(self, message, code): super().__init__(message, code)
Base account error that all other account errors derive from.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
Subclasses
class AnonymousError
-
Expand source code
class AnonymousError(AuthorizationError): """Raised when attempting to authorize an anonymous user.""" def __init__(self): super().__init__("Session is anonymous.")
Raised when attempting to authorize an anonymous user.
Ancestors
- AuthorizationError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class AuditWarning (*args, **kwargs)
-
Expand source code
class AuditWarning(Warning): """Raised when configuration may be dangerous."""
Raised when configuration may be dangerous.
Ancestors
- builtins.Warning
- builtins.Exception
- builtins.BaseException
class AuthorizationError (message)
-
Expand source code
class AuthorizationError(SecurityError): """Raised when an account has insufficient permissions or roles for an action.""" def __init__(self, message): super().__init__(message, 403)
Raised when an account has insufficient permissions or roles for an action.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
Subclasses
class ChallengeError (message)
-
Expand source code
class ChallengeError(SessionError): """Raised when a session challenge attempt is invalid.""" def __init__(self, message): super().__init__(message)
Raised when a session challenge attempt is invalid.
Ancestors
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
Subclasses
class CredentialsError (message, code=400)
-
Expand source code
class CredentialsError(SecurityError): """Raised when credentials are invalid.""" def __init__(self, message, code=400): super().__init__(message, code)
Raised when credentials are invalid.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class DeactivatedError (message: str = 'Session has been deactivated.', code: int = 401)
-
Expand source code
class DeactivatedError(SessionError): """Raised when session is deactivated.""" def __init__( self, message: str = "Session has been deactivated.", code: int = 401, ): super().__init__(message, code)
Raised when session is deactivated.
Ancestors
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class DeletedError (message)
-
Expand source code
class DeletedError(SecurityError): """Raised when attempting to access a resource marked as deleted.""" def __init__(self, message): super().__init__(message, 404)
Raised when attempting to access a resource marked as deleted.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class DisabledError (message: str = 'Account is disabled.', code: int = 401)
-
Expand source code
class DisabledError(AccountError): """Raised when account is disabled.""" def __init__(self, message: str = "Account is disabled.", code: int = 401): super().__init__(message, code)
Raised when account is disabled.
Ancestors
- AccountError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class ExpiredError (message='Session has expired.')
-
Expand source code
class ExpiredError(SessionError): """Raised when session has expired.""" def __init__(self, message="Session has expired."): super().__init__(message)
Raised when session has expired.
Ancestors
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class JWTDecodeError (message='Session token invalid, not provided, or expired.', code=401)
-
Expand source code
class JWTDecodeError(SessionError): """Raised when client JWT is invalid.""" def __init__( self, message="Session token invalid, not provided, or expired.", code=401 ): super().__init__(message, code)
Raised when client JWT is invalid.
Ancestors
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class MaxedOutChallengeError
-
Expand source code
class MaxedOutChallengeError(ChallengeError): """Raised when a session's challenge attempt limit is reached.""" def __init__(self): super().__init__("The maximum amount of attempts has been reached.")
Raised when a session's challenge attempt limit is reached.
Ancestors
- ChallengeError
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class NotFoundError (message)
-
Expand source code
class NotFoundError(SecurityError): """Raised when a resource cannot be found on the database.""" def __init__(self, message): super().__init__(message, 404)
Raised when a resource cannot be found on the database.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class OAuthError (message, code=401)
-
Expand source code
class OAuthError(SecurityError): """Raised when an error occurs during OAuth flow.""" def __init__(self, message, code=401): super().__init__(message, code)
Raised when an error occurs during OAuth flow.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class SecondFactorRequiredError
-
Expand source code
class SecondFactorRequiredError(SessionError): """Raised when authentication session two-factor requirement isn't met.""" def __init__(self): super().__init__("Session requires second factor for authentication.")
Raised when authentication session two-factor requirement isn't met.
Ancestors
- SessionError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
class SecurityError (message: str, code: int)
-
Expand source code
class SecurityError(SanicException): """ Sanic Security related error. Attributes: json (HTTPResponse): Security error json response. Args: message (str): Human readable error message. code (int): HTTP error code. """ def __init__(self, message: str, code: int): self.json = json(message, self.__class__.__name__, code) super().__init__(message, code)
Sanic Security related error.
Attributes
json
:HTTPResponse
- Security error json response.
Args
message
:str
- Human readable error message.
code
:int
- HTTP error code.
Ancestors
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
Subclasses
class SessionError (message, code=401)
-
Expand source code
class SessionError(SecurityError): """Base session error that all other session errors derive from.""" def __init__(self, message, code=401): super().__init__(message, code)
Base session error that all other session errors derive from.
Ancestors
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException
Subclasses
class UnverifiedError
-
Expand source code
class UnverifiedError(AccountError): """Raised when account is unverified.""" def __init__(self): super().__init__("Account requires verification.", 401)
Raised when account is unverified.
Ancestors
- AccountError
- SecurityError
- sanic.exceptions.SanicException
- builtins.Exception
- builtins.BaseException