Skip to content

Return 403 when Keycloak UMA ticket grant returns invalid_grant - #73234

Merged
vincbeck merged 3 commits into
apache:mainfrom
shashank-iitbhu:fix-keycloak-uma-invalid-grant-500
Sep 21, 2026
Merged

vincbeck merged 3 commits into
apache:mainfrom
shashank-iitbhu:fix-keycloak-uma-invalid-grant-500

Conversation

@shashank-iitbhu

Copy link
Copy Markdown
Contributor

Keycloak's UMA uma-ticket grant often returns HTTP 400 invalid_grant / Invalid bearer token when the nested Keycloak access token has expired. _is_authorized and _is_batch_authorized currently raise AirflowException for that 400, which the API server surfaces as HTTP 500.

401 is already treated as unauthorized (#59281). 400 invalid_resource on team resources is already treated as deny (#69028). This maps 400 invalid_grant onto the same deny path so API clients get 403 instead of 500 and can remint.

invalid_scope and other unrecognized 400s still raise.

closes: #73232

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
  • No

Generated-by: Cursor following the guidelines

@boring-cyborg

boring-cyborg Bot commented Sep 16, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@vincbeck vincbeck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix static checks

shashank-iitbhu and others added 3 commits September 21, 2026 08:16
…he#73232)

Keycloak's uma-ticket grant often returns HTTP 400 invalid_grant when the
nested access token used as bearer is expired. Treat that the same as 401
so the API returns 403 instead of raising AirflowException as HTTP 500.

Signed-off-by: Shashank Mittal <[email protected]>
@eladkal
eladkal force-pushed the fix-keycloak-uma-invalid-grant-500 branch from ea3f541 to fecaf5e Compare September 21, 2026 05:17
@vincbeck
vincbeck merged commit 2c98ac7 into apache:main Sep 21, 2026
79 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 21, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keycloak UMA invalid_grant (HTTP 400) on expired access token is raised as API 500

4 participants