Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow CORS headers for preflight requests #5843

Closed
maany opened this issue Aug 26, 2022 · 0 comments · Fixed by #5844
Closed

allow CORS headers for preflight requests #5843

maany opened this issue Aug 26, 2022 · 0 comments · Fixed by #5844

Comments

@maany
Copy link
Member

maany commented Aug 26, 2022

Motivation

For requests that are unsafe OR cross-origin, browsers make a preflight request to the Rucio Server. A preflight request is essentially an OPTIONS ( HTTP method) to the same endpoint where the actual request was intended.

The old WebUI never had the requirement of handling pre-flight requests, since the requests always went to the WebUI flask server, which was available on the same apache host as the rucio server:

host = window.location.host;
this.url = 'https://' + host + '/proxy';
this.authurl = 'https://' + host + '/auth';

Besides the auth server, no other endpoints had to handle the HTTP OPTIONS request.

user_pass_view = UserPass.as_view('user_pass')
bp.add_url_rule('/userpass', view_func=user_pass_view, methods=['get', 'options'])
gss_view = GSS.as_view('gss')
bp.add_url_rule('/gss', view_func=gss_view, methods=['get', 'options'])
x509_view = x509.as_view('x509')
bp.add_url_rule('/x509', view_func=x509_view, methods=['get', 'options'])
bp.add_url_rule('/x509_proxy', view_func=x509_view, methods=['get', 'options'])

However, the new UI is a React application running in the browser and any request that is made to the rucio server invokes the CORS preflight request. All of these preflight requests are blocked as the the rucio server does not handle the OPTIONS HTTP methods. (anywhere besides auth endpoints)

As a result, while the new WebUI can successfully obtain the rucio token, any subsequent request made to other endpoints of the rucio server fail.

Modification

Add a flask middleware to filter for OPTIONS requests and respond to the them with a 200 OK response if they originate from the WebUI URLs specified in the appropriate rucio.cfg section

@maany maany self-assigned this Aug 26, 2022
maany added a commit to maany/rucio that referenced this issue Aug 26, 2022
maany added a commit to maany/rucio that referenced this issue Aug 26, 2022
maany added a commit to maany/rucio that referenced this issue Aug 26, 2022
maany added a commit to maany/rucio that referenced this issue Aug 26, 2022
maany added a commit to maany/rucio that referenced this issue Aug 26, 2022
bari12 added a commit that referenced this issue Aug 29, 2022
@bari12 bari12 added the feature label Aug 29, 2022
@bari12 bari12 added this to the 1.29.4 milestone Aug 29, 2022
maany added a commit to maany/rucio that referenced this issue Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants