mirror of
https://github.com/yweber/lodel2.git
synced 2026-03-22 02:52:02 +01:00
Added documentation on the lodel/auth/exceptions.py module
This commit is contained in:
parent
1e7b93db52
commit
5d43f04276
1 changed files with 28 additions and 11 deletions
|
|
@ -1,14 +1,18 @@
|
||||||
|
# @package lodel.auth.exceptions
|
||||||
|
# @brief Defines the specific exceptions used in the authentication process
|
||||||
|
|
||||||
from lodel.context import LodelContext
|
from lodel.context import LodelContext
|
||||||
|
|
||||||
LodelContext.expose_modules(globals(), {
|
LodelContext.expose_modules(globals(), {
|
||||||
'lodel.logger': 'logger',
|
'lodel.logger': 'logger',
|
||||||
'lodel.plugin.hooks': ['LodelHook']})
|
'lodel.plugin.hooks': ['LodelHook']})
|
||||||
|
|
||||||
|
|
||||||
## @brief Handles common errors with a Client
|
## @brief Handles common errors with a Client
|
||||||
class ClientError(Exception):
|
class ClientError(Exception):
|
||||||
## @brief The logger function to use to log the error message
|
## @brief The logger function to use to log the error message
|
||||||
_loglvl = 'warning'
|
_loglvl = 'warning'
|
||||||
##@brief Error str
|
## @brief Error string
|
||||||
_err_str = "Error"
|
_err_str = "Error"
|
||||||
## @brief the hook name to trigger with error
|
## @brief the hook name to trigger with error
|
||||||
_action = 'lodel2_ui_error'
|
_action = 'lodel2_ui_error'
|
||||||
|
|
@ -17,8 +21,10 @@ class ClientError(Exception):
|
||||||
|
|
||||||
## @brief Constructor
|
## @brief Constructor
|
||||||
#
|
#
|
||||||
#Log message are build using the following format :
|
# Log messages are built using the following format :
|
||||||
# "<client infos> : <_err_str>[ : <msg>]"
|
# "<client infos> : <_err_str>[ : <msg>]"
|
||||||
|
# @param client Client : object containing the client's data
|
||||||
|
# @param msg str : message string to use
|
||||||
def __init__(self, client, msg = ""):
|
def __init__(self, client, msg = ""):
|
||||||
msg = self.build_message(client, msg)
|
msg = self.build_message(client, msg)
|
||||||
if self._loglvl is not None:
|
if self._loglvl is not None:
|
||||||
|
|
@ -28,30 +34,41 @@ class ClientError(Exception):
|
||||||
if self._action is not None:
|
if self._action is not None:
|
||||||
LodelHook.call_hook(self._action, self, self._payload)
|
LodelHook.call_hook(self._action, self, self._payload)
|
||||||
|
|
||||||
##@brief build error message
|
## @brief Builds an error message
|
||||||
|
# @param client Client
|
||||||
|
# @param msg str
|
||||||
def build_message(self, client, msg):
|
def build_message(self, client, msg):
|
||||||
res = "%s : %s" % (client, self._err_str)
|
res = "%s : %s" % (client, self._err_str)
|
||||||
if len(msg) > 0:
|
if len(msg) > 0:
|
||||||
res += " : %s" % msg
|
res += " : %s" % msg
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
## @brief Handles authentication failure errors
|
## @brief Handles authentication failure errors
|
||||||
class ClientAuthenticationFailure(ClientError):
|
class ClientAuthenticationFailure(ClientError):
|
||||||
|
## @brief Log Level
|
||||||
_loglvl = 'security'
|
_loglvl = 'security'
|
||||||
|
## @brief Error string
|
||||||
_err_str = 'Authentication failure'
|
_err_str = 'Authentication failure'
|
||||||
|
## @brief Hook to trigger
|
||||||
_action = 'lodel2_ui_authentication_failure'
|
_action = 'lodel2_ui_authentication_failure'
|
||||||
|
|
||||||
|
|
||||||
##@brief Handles permission denied errors
|
##@brief Handles permission denied errors
|
||||||
class ClientPermissionDenied(ClientError):
|
class ClientPermissionDenied(ClientError):
|
||||||
|
## @brief Log level
|
||||||
_loglvl = 'security'
|
_loglvl = 'security'
|
||||||
|
## @brief Error string
|
||||||
_err_str = 'Permission denied'
|
_err_str = 'Permission denied'
|
||||||
|
## @brief Hook to trigger
|
||||||
_action = 'lodel2_ui_permission_denied'
|
_action = 'lodel2_ui_permission_denied'
|
||||||
|
|
||||||
|
|
||||||
##@brief Handles common errors on authentication
|
##@brief Handles common errors on authentication
|
||||||
class ClientAuthenticationError(ClientError):
|
class ClientAuthenticationError(ClientError):
|
||||||
|
## @brief Log level
|
||||||
_loglvl = 'error'
|
_loglvl = 'error'
|
||||||
|
## @brief Error string
|
||||||
_err_str = 'Authentication error'
|
_err_str = 'Authentication error'
|
||||||
|
## @brief Hook to trigger
|
||||||
_action = 'lodel2_ui_error'
|
_action = 'lodel2_ui_error'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue