code: def basic_auth_required(self, func):
          
  
          def make_auth_required_response():
              response = make_response('Unauthorized', 401)
              response.www_authenticate.set_basic(
                  current_app.config['LDAP_REALM_NAME'])
              return response
  
          @wraps(func)
          def wrapped(*args, **kwargs):
              if request.authorization is None:
                  req_username = None
                  req_password = None
              else:
                  req_username = request.authorization.username
                  req_password = request.authorization.password
  
              # Many LDAP servers will grant you anonymous access if you log in
              # with an empty password, even if you supply a non-anonymous user
              # ID, causing .bind_user() to return True. Therefore, only accept
              # non-empty passwords.
              if req_username in ['', None] or req_password in ['', None]:
                  current_app.logger.debug('Got a request without auth data')
                  return make_auth_required_response()
  
              if not self.bind_user(req_username, req_password):
                  current_app.logger.debug('User {0!r} gave wrong '
                                           'password'.format(req_username))
                  return make_auth_required_response()
  
              g.ldap_username = req_username
              g.ldap_password = req_password
  
              return func(*args, **kwargs)
  
          return wrapped
docs: When applied to a view function, any unauthenticated requests are
          asked to authenticate via HTTP's standard Basic Authentication system.
          Requests with credentials are checked with :meth:`.bind_user()`.
  
          The user's browser will typically show them the contents of
          LDAP_REALM_NAME as a prompt for which username and password to enter.
  
          If the request's credentials are accepted by the LDAP server, the
          username is stored in ``flask.g.ldap_username`` and the password in
          ``flask.g.ldap_password``.
  
          :param func: The view function to decorate.