docker_leash.checks package¶
Submodules¶
docker_leash.checks.allow module¶
Allow¶
-
class
Allow
[source]¶ Bases:
docker_leash.checks.base.BaseCheck
A simple module that say yes.
docker_leash.checks.base module¶
Base¶
-
class
BaseCheck
[source]¶ Bases:
object
The
BaseCheck
class is the base class for all the checks-
static
replace_user
(value, payload)[source]¶ A helper function to replace $USER in string
If exact match is found, the replace is done by the value of the current connected user. If no user defined, then it return None. If ‘$’ is preceded by a
\
(backslash), then no substitution is done.>>> payload = payload({"User": "mal"}) >>> BaseCheck.replace_user("$USER-loves-me", payload) mal-loves-me
>>> payload = payload({"User": "mal"}) >>> BaseCheck.replace_user("\$USER-loves-me", payload) $USER-loves-me
>>> payload = payload({"User": None}) >>> BaseCheck.replace_user("$USER-loves-me", payload) # Return None >>> payload = payload({}) >>> BaseCheck.replace_user("$USER-loves-me", payload) # Return None
It works with list too:
>>> a = ["who-loves-you", "$USER-loves-me", "\$USER-loves-me"] >>> payload = payload({"User": "mal"}) >>> BaseCheck.replace_user("$USER-loves-me", payload) ["who-loves-you", "mal-loves-me", "\$USER-loves-me"]
Parameters: - value (string or list or None) – The input to replace
- payload (
docker_leash.payload.Payload
) – The payload of the current request.
Returns: The replaced value(s)
Return type:
-
run
(args, payload)[source]¶ Run the module checks.
The implemented check module receive the global configuration and the current payload. It is autonomous in how the checks are implemented.
If the requested action should be forbidden then the module must raise an
docker_leash.exceptions.UnauthorizedException
.Warning
This function must be overridden in each check modules.
Parameters: - args (list or dict or str or None) – The module arguments, from the configuration
- payload (docker_leash.payload.Payload) – payload of the current request
-
static
docker_leash.checks.deny module¶
Deny¶
-
class
Deny
[source]¶ Bases:
docker_leash.checks.base.BaseCheck
A simple module that say no
-
run
(args, payload)[source]¶ Run the module checks.
Saying no is easy, just raise an
docker_leash.exceptions.UnauthorizedException
;^)Parameters: - args (list or dict or str or None) – The module arguments from the config
- payload (docker_leash.payload.Payload) – payload of the current request
-