linotp.lib.policy.action module¶
policy action processing
- class linotp.lib.policy.action.PolicyActionTyping¶
Bases:
objectConvert the action value according to the policy definition.
- convert(scope: str, action_name: str, action_value: Union[bool, int, str]) Any¶
Convert the action values acording to the policy definitions.
- Paran scope:
of the action
- Parameters:
action_name – the name of the action
action_value – the un parsed action value
- Returns:
the typed value
- convert_actions(scope: str, actions: Dict) Dict¶
type conversion of an action dict.
utility to be used in the by functions like get_selfservice_actions to make the code better readable
- Parameters:
scope – the scope of the action in the policy definition
actions – dict with actions
- Returns:
dict with all action and their converted values
- exception linotp.lib.policy.action.PolicyConversionError(message)¶
Bases:
Exception
- linotp.lib.policy.action.get_action_value(policies: Dict, scope: str, action: str, subkey: str = None, default: Any = None) Any¶
Get the value of an action from a set of policies
- Parameters:
policies – a dict of policies
scope – the scope of the policy - required for the typing support
action – the name of the searched action
subkey – special feature to support action names with sub keys
default – the default return if nothing is found
- Returns:
the (typed) action value or default
- linotp.lib.policy.action.get_selfservice_action_value(action: str, user: User = None, default: Any = None) Any¶
Helper to get the value for a selfservice action.
- Parameters:
user – the authenticated user
action – the action name
default – the fallback value, if no policy action is found
- Returns:
the (typed) value of the action
- linotp.lib.policy.action.get_selfservice_actions(user=None, action=None)¶
This function returns the allowed actions in the self service portal for the given user
if there was an action as parameter, we copy only this one into the result set
action value will be type converted according to the policy definition
- Returns:
dictionary with all actions