apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
35.44k stars 13.84k forks source link

Unable to pass {username} with slashes to Airflow REST API #39887

Open wilsonhooi86 opened 1 month ago

wilsonhooi86 commented 1 month ago

Apache Airflow version

Other Airflow 2 version (please specify below)

If "Other Airflow 2 version" selected, which one?

2.8.1

What happened?

MWAA has announced that we can now use Airflow REST API. The goal is to use REST API Patch User to add/remove users' roles programmatically.

MWAA create username with a prefix of assumed-role/ for each user login. Example {username}: assumed-role/user1 .

API Template URL: https://airflow.apache.org/auth/fab/v1/users/assumed_role/{username} Actual URL: https://airflow.apache.org/auth/fab/v1/users/assumed_role/assumed-role/user1

As we call the Airflow REST API https://airflow.apache.org/auth/fab/v1/users/assumed_role/assumed-role/user1 , it will show below error:

{
"detail": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404,
"title": "Not Found",
"type": "about:blank"
}

We believe the REST API render the slash as an URL path.

Question is, can we enhance the Airflow REST API to accept slashes in URL parameter?

What you think should happen instead?

Airflow REST API able to accept slashes in URL parameter. Example: username: assumed-role/user1 https://airflow.apache.org/auth/fab/v1/users/assumed-role/user1

How to reproduce

Please refer to What Happened? section

Operating System

MWAA

Versions of Apache Airflow Providers

No response

Deployment

Amazon (AWS) MWAA

Deployment details

I am not sure that this issue is specific to the service provider.

Anything else?

No response

Are you willing to submit PR?

Code of Conduct

boring-cyborg[bot] commented 1 month ago

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

Taragolis commented 1 month ago

Airflow REST API able to accept slashes in URL parameter. Example:

It shouldn't. / have a special meaning for separate paths in URI. Instead of that it should work with url-encoded values, did you try to provide assumed-role%2Fuser1 instead?

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been open for 14 days with no response from the author. It will be closed in next 7 days if no further activity occurs from the issue author.

wilsonhooi86 commented 1 month ago

Airflow REST API able to accept slashes in URL parameter. Example:

It shouldn't. / have a special meaning for separate paths in URI. Instead of that it should work with url-encoded values, did you try to provide assumed-role%2Fuser1 instead?

Hi @Taragolis , yes, I tried to pass in as assumed-role%2Fuser1 but it still parse as "/" in the url and produce the same error as below:

{
"detail": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404,
"title": "Not Found",
"type": "about:blank"
}