def group_required(self, group):
        """Decorator which checks if user is in group

        Decorator for Flask's view which blocks requests from not
        authenticated users or if user is not member of specified group

        :param group: group's name
        """

        def decorator(view):
            @functools.wraps(view)
            def decorated(*args, **kwargs):
                log.info("Trying to get access to resource: %s protected by group: %s", view.__name__, group)
                if request.method == 'POST':
                    token = request.form['token']
                    if self.development or self.group_authenticated(token, group):
                        return view(*args, **kwargs)
                    else:
                        log.warning("User has not been authorized to get access to resource: %s", view.__name__)
                else:
                    log.error("Bad request type! Expected 'POST', actual '%s'", request.method)

                return abort(403)

            return decorated
        return decorator
def group_required ( self , group ) : def decorator ( view ) : @ functools . wraps ( view ) def decorated ( * args , ** kwargs ) : log . info ( "Trying to get access to resource: %s protected by group: %s" , view . __name__ , group ) if request . method == 'POST' : token = request . form [ 'token' ] if self . development or self . group_authenticated ( token , group ) : return view ( * args , ** kwargs ) else : log . warning ( "User has not been authorized to get access to resource: %s" , view . __name__ ) else : log . error ( "Bad request type! Expected 'POST', actual '%s'" , request . method ) return abort ( 403 ) return decorated return decorator
Decorator which checks if user is in group

        Decorator for Flask's view which blocks requests from not
        authenticated users or if user is not member of specified group

        :param group: group's name