

def _handle_proxy_auth(self, request, **kwargs):
    remote_addr = pecan.request.headers.get('x-forwarded-for', pecan.request.remote_addr)
    extra = {
        'remote_addr': remote_addr,
    }
    if pecan.request.remote_user:
        ttl = getattr(request, 'ttl', None)
        try:
            token = self._create_token_for_user(username=pecan.request.remote_user, ttl=ttl)
        except TTLTooLargeException as e:
            self._abort_request(status_code=http_client.BAD_REQUEST, message=e.message)
        return self._process_successful_response(token=token)
    LOG.audit('Access denied to anonymous user.', extra=extra)
    self._abort_request()

dataset/ETHPy150Open StackStorm/st2/st2auth/st2auth/controllers/v1/auth.py TokenController._handle_proxy_auth/original