[elbe-devel] [PATCH v2 02/10] soap authentication: support 6 arguments in @authenticated_admin decorator

Manuel Traut manuel.traut at linutronix.de
Wed Apr 18 16:36:41 CEST 2018


On Tue, Apr 17, 2018 at 12:39:33PM +0200, Torben Hohn wrote:
> The docorators have an implemetation for for each number of arguments.
> When we want to decorate a function with 6 arguments, we need an
> implementation there.
> 
> This is a preparation for the add_user command.
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

Reviewed-by: Manuel Traut <manut at linutronix.de>

and will be added to devel/elbe-3.0

please remember to update your copyright statement in the header. This time,
i'll fix it up manually.

Thanks,

  Manuel



> ---
>  elbepack/daemons/soap/authentication.py | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/elbepack/daemons/soap/authentication.py b/elbepack/daemons/soap/authentication.py
> index 787cab3c..051bc09c 100644
> --- a/elbepack/daemons/soap/authentication.py
> +++ b/elbepack/daemons/soap/authentication.py
> @@ -155,6 +155,19 @@ def authenticated_admin(func):
>                  raise SoapElbeNotAuthorized()
>              return func(self, arg1, arg2)
>          return wrapped
> +    elif func.__code__.co_argcount == 6:
> +        @wraps(func)
> +        def wrapped(self, arg1, arg2, arg3, arg4, arg5):
> +            s = self.transport.req_env['beaker.session']
> +            try:
> +                uid = s['userid']
> +            except KeyError:
> +                raise SoapElbeNotLoggedIn()
> +
> +            if not self.app.pm.db.is_admin(uid):
> +                raise SoapElbeNotAuthorized()
> +            return func(self, arg1, arg2, arg3, arg4, arg5)
> +        return wrapped
>      else:
>          raise Exception(
>              "arg count %d not implemented" %
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list