adhocracy_core.authentication package¶
Authentication with support for token http headers.
-
UserTokenHeader= 'X-User-Token'¶ The request header parameter to set the authentication token.
-
UserPasswordHeader= 'X-User-Password'¶ The request header parameter to set the user password.
-
UserPathHeader= 'X-User-Path'¶ Deprecated: The optional request header to set the userid.
-
AnonymizeHeader= 'X-Anonymize'¶ Mark this request to be anonymized.
-
class
TokenHeaderAuthenticationPolicy(private_key: str, callback: <built-in function callable>=None, timeout: int=10, algorithm='HS512')[source]¶ Bases:
pyramid_jwt.policy.JWTAuthenticationPolicyHttp header token authentication based on
pyramid_jwt.The following methods are extendend:
- remember return a list with the header/value to authenticate
- effective_principals cache principals for one request
-
validate_user_headers(view: <built-in function callable>)[source]¶ Decorator vor view to check if the user token.
Raises: pyramid.httpexceptions.HTTPBadRequest – if user token is invalid
-
has_password_header(request: <InterfaceClass pyramid.interfaces.IRequest>) → bool[source]¶ Check if request provided the password in the Password header.
-
get_header_password(request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return the password in the Password header.
-
validate_password_header(view: <built-in function callable>)[source]¶ Decorator vor view to check if the password header may be set.
Raises: pyramid.httpexceptions.HTTPBadRequest – if password is invalid or not required. The case that a password is required by a sheet but not set cannot be handled here, as we do not know which sheets are edited by the request.
-
is_marked_anonymize(request: <InterfaceClass pyramid.interfaces.IRequest>) → bool[source]¶ Check if request is marked with the Anonymize header.
-
validate_anonymize_header(view: <built-in function callable>)[source]¶ Decorator vor view to check if the anonymize header may be set.
Raises: pyramid.httpexceptions.HTTPBadRequest – if anonymize header is set but is not allowed
-
class
MultiRouteAuthenticationPolicy[source]¶ Bases:
pyramid.authentication.CallbackAuthenticationPolicyUse different policy to authenticate depending on the request route.
-
add_policy(route_name: str, policy: <InterfaceClass pyramid.interfaces.IAuthenticationPolicy>)[source]¶ Add policy for route_name.
-
unauthenticated_userid(request: <InterfaceClass pyramid.interfaces.IRequest>) → str[source]¶ Return unauthenticated_userid of policy with matching route name.
-
effective_principals(request: <InterfaceClass pyramid.interfaces.IRequest>)[source]¶ Return principals of policy with matching route name.
-
-
set_anonymized_creator(context: object, userid: str)[source]¶ Store userid of anonymized creator of context.