def logout(request): external_domain = 'HTTP_ORIGIN' in request.META # Check if the logout request is originated in a different domain if external_domain: origin = request.META['HTTP_ORIGIN'] if origin not in ALLOWED_ORIGINS: return build_error_response(request, 403, '') # Force not redirect by using next_page=None response = wirecloud_logout(request, next_page=None) response['Access-Control-Allow-Origin'] = origin response['Access-Control-Allow-Credentials'] = 'true' return response else: return wirecloud_logout(request)
def logout(request): external_domain = 'HTTP_ORIGIN' in request.META # Check if the logout request is originated in a different domain if external_domain: origin = request.META['HTTP_ORIGIN'] if origin not in ALLOWED_ORIGINS: return build_error_response(request, 403, '') # Force not redirect by using next_page=None response = wirecloud_logout(request, next_page=None) response['Access-Control-Allow-Origin'] = origin response['Access-Control-Allow-Credentials'] = 'true' return response elif callable( request.user.is_authenticated) and request.user.is_authenticated( ) or request.user.is_authenticated is True: backend = build_backend() next_page = str( getattr(settings, 'LOGOUT_REDIRECT_URL', get_absolute_reverse_url('wirecloud.root', request))) if REDIRECT_FIELD_NAME in request.GET: url_next_page = request.GET.get(REDIRECT_FIELD_NAME) url_is_safe = is_safe_url( url=url_next_page, allowed_hosts={request.get_host()}, require_https=request.is_secure(), ) if url_is_safe: next_page = url_next_page keycloak_logout_url = backend.end_session_url( ) + '?redirect_uri=' + quote(request.build_absolute_uri(next_page)) request.GET = {} return wirecloud_logout(request, next_page=keycloak_logout_url) else: return wirecloud_logout(request)
def logout(request): response = HttpResponse(status=204) # Check if the logout request is originated in a different domain if 'HTTP_ORIGIN' in request.META: origin = request.META['HTTP_ORIGIN'] if origin in ALLOWED_ORIGINS: response['Access-Control-Allow-Origin'] = origin response['Access-Control-Allow-Credentials'] = 'true' else: response = build_error_response(request, 403, '') if request.method == 'GET' and response.status_code == 204: return wirecloud_logout(request) return response