Skip to content

Affix webserver access_denied warning to be configurable#33022

Merged
eladkal merged 3 commits into
apache:mainfrom
amoghrajesh:changeAccessDeniedMessage
Aug 3, 2023
Merged

Affix webserver access_denied warning to be configurable#33022
eladkal merged 3 commits into
apache:mainfrom
amoghrajesh:changeAccessDeniedMessage

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Add a possibility to make the airflow webserver's access denied message - which occurs when an user tries to perform some operation outside their user rights. Allow this to be configurable through config so that every webserver installation can have a custom message without changing the airflow code.

Note: This message is not per call to the has_access function, but per webserver installation which is a more realistic case.

Took suggestions from community and approached the problem accordingly.

  • Made a function get_access_denied_message so that the "unit" is testable.

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg Bot added the area:webserver Webserver related Issues label Aug 2, 2023
@amoghrajesh
amoghrajesh requested a review from vincbeck August 2, 2023 04:18
@eladkal eladkal added this to the Airflow 2.7.0 milestone Aug 2, 2023
@eladkal eladkal added the type:improvement Changelog: Improvements label Aug 2, 2023
Comment thread airflow/www/auth.py


def get_access_denied_message():
return conf.get("webserver", "access_denied_message")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should either use get_mandatory or provide a fallback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not really. The get_mandatory is needed only when we want to have a value but the value has no default (for example when we want to get a URL that has no default but we really need it to be configured).

The way it works when it is put in config.yml is that "default" is automatically used as fallback if there is no fallback (It's been working like that already for quite some time via defaul_config.cfg - so my recent change has not changed it - jut made it works without the default_config.cfg

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is needed as @potiuk mentions here. The older default text is passed as the default in the new property in config.yml, which is basically the fallback.

@amoghrajesh
amoghrajesh requested review from potiuk and uranusjr August 2, 2023 13:54

@pankajkoti pankajkoti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, minor cosmetic suggestions if you'd like to consider :)

Comment thread airflow/config_templates/config.yml Outdated
options:
access_denied_message:
description: |
The message displayed when an user tries to perform operations outside their rights.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The message displayed when an user tries to perform operations outside their rights.
The notification that appears when a user attempts to execute actions beyond their authorised privileges.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would like to keep it as message because this is not a notification. Maybe I can term it to warning instead

@pankajkoti pankajkoti Aug 2, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

okay so
"The message displayed when a user attempts to execute actions beyond their authorised privileges."
?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If not, the minimum suggestion is to correct an user to a user 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah why not, thanks, making the changes

version_added: 2.7.0
type: string
example: ~
default: "Access is Denied"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
default: "Access is Denied"
default: "Unauthorized Access: Denied"

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.

I dont think we can do that. The current message is "Access is Denied" so in order to keep the current experience, we got to have this default value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. We do not want to break the backward compatibility experience. If we want to make this change, we should have a different task for it instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @vincbeck

version_added: 2.7.0
type: string
example: ~
default: "Access is Denied"

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.

I dont think we can do that. The current message is "Access is Denied" so in order to keep the current experience, we got to have this default value

@amoghrajesh
amoghrajesh requested a review from pankajkoti August 2, 2023 17:04
version_added: 2.7.0
type: string
example: ~
default: "Access is Denied"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @vincbeck

Comment thread tests/www/test_security.py Outdated
@hussein-awala

Copy link
Copy Markdown
Member

Waiting for a second look from @uranusjr before merge

@eladkal eladkal 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.

Lets merge so it won't miss 2.7.0
we can modify in followup PR if needed

@eladkal
eladkal merged commit 12a760f into apache:main Aug 3, 2023
ephraimbuddy pushed a commit that referenced this pull request Aug 3, 2023
* Affix webserver access_denied warning to be configurable

(cherry picked from commit 12a760f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webserver Webserver related Issues type:improvement Changelog: Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants