code: def group_required(groups=None):
          
  
          def wrapper(func):
              @wraps(func)
              def wrapped(*args, **kwargs):
                  if g.user is None:
                      return redirect(
                          url_for(current_app.config['LDAP_LOGIN_VIEW'],
                                  next=request.path))
                  match = [group for group in groups if group in g.ldap_groups]
                  if not match:
                      abort(401)
  
                  return func(*args, **kwargs)
  
              return wrapped
  
          return wrapper
docs: When applied to a view function, any unauthenticated requests will
          be redirected to the view named in LDAP_LOGIN_VIEW. Authenticated
          requests are only permitted if they belong to one of the listed groups.
  
          The login view is responsible for asking for credentials, checking
          them, and setting ``flask.g.user`` to the name of the authenticated
          user and ``flask.g.ldap_groups`` to the authenticated user's groups
          if the credentials are acceptable.
  
          :param list groups: List of groups that should be able to access the
              view function.