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
Fix kerberos authentication for the REST API. #29054
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 tasks
BMFH
reviewed
Jan 20, 2023
@@ -141,7 +143,7 @@ def decorated(*args, **kwargs): | |||
token = "".join(header.split()[1:]) | |||
return_code = _gssapi_authenticate(token) | |||
if return_code == kerberos.AUTH_GSS_COMPLETE: | |||
g.user = ctx.kerberos_user | |||
g.user = get_airflow_app().appbuilder.sm.find_user(email=ctx.kerberos_user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works. In case when email domain not equal kerberos realm I suggest to look user by username field. It works too.
potiuk
force-pushed
the
check-email-use-in-kerberos-auth
branch
from
January 20, 2023 12:19
2232a93
to
f159080
Compare
potiuk
changed the title
[Experimental] Treat kerberos identity as email in authentication
Fix kerberos authentication for the REST API.
Jan 20, 2023
Previously we assigned kerberos user name directly to the flask user, but this had no chance to work because we expect FAB user there and our security code crash with 'str' has no attribute 'perms'. This PR uses Kerberos username (including the Kerberos realm) to retrieve the user from the security manager. This means that the user name has to have the form of `user_name@KERBEROS_REALM`. The reason why we are not using email (despite similarities of the realm and domain name is that those are often different. Email domain names have often nothing to do the with the realms within organisations, and it seems safer to put fully qualified names including the realm in order to uniquely identify the users in case the organisation uses more than one REALM. Fixes: apache#28919 Co-authored-by: BMFH <bogner85@mail.ru>
potiuk
force-pushed
the
check-email-use-in-kerberos-auth
branch
from
January 20, 2023 12:22
f159080
to
b364ee7
Compare
mik-laj
approved these changes
Jan 20, 2023
maggesssss
pushed a commit
to maggesssss/airflow
that referenced
this pull request
Jan 21, 2023
Previously we assigned kerberos user name directly to the flask user, but this had no chance to work because we expect FAB user there and our security code crash with 'str' has no attribute 'perms'. This PR uses Kerberos username (including the Kerberos realm) to retrieve the user from the security manager. This means that the user name has to have the form of `user_name@KERBEROS_REALM`. The reason why we are not using email (despite similarities of the realm and domain name is that those are often different. Email domain names have often nothing to do the with the realms within organisations, and it seems safer to put fully qualified names including the realm in order to uniquely identify the users in case the organisation uses more than one REALM. Fixes: apache#28919 Co-authored-by: BMFH <bogner85@mail.ru> Co-authored-by: BMFH <bogner85@mail.ru>
pierrejeambrun
pushed a commit
that referenced
this pull request
Mar 7, 2023
Previously we assigned kerberos user name directly to the flask user, but this had no chance to work because we expect FAB user there and our security code crash with 'str' has no attribute 'perms'. This PR uses Kerberos username (including the Kerberos realm) to retrieve the user from the security manager. This means that the user name has to have the form of `user_name@KERBEROS_REALM`. The reason why we are not using email (despite similarities of the realm and domain name is that those are often different. Email domain names have often nothing to do the with the realms within organisations, and it seems safer to put fully qualified names including the realm in order to uniquely identify the users in case the organisation uses more than one REALM. Fixes: #28919 Co-authored-by: BMFH <bogner85@mail.ru> Co-authored-by: BMFH <bogner85@mail.ru> (cherry picked from commit 135aef3)
pierrejeambrun
pushed a commit
that referenced
this pull request
Mar 8, 2023
Previously we assigned kerberos user name directly to the flask user, but this had no chance to work because we expect FAB user there and our security code crash with 'str' has no attribute 'perms'. This PR uses Kerberos username (including the Kerberos realm) to retrieve the user from the security manager. This means that the user name has to have the form of `user_name@KERBEROS_REALM`. The reason why we are not using email (despite similarities of the realm and domain name is that those are often different. Email domain names have often nothing to do the with the realms within organisations, and it seems safer to put fully qualified names including the realm in order to uniquely identify the users in case the organisation uses more than one REALM. Fixes: #28919 Co-authored-by: BMFH <bogner85@mail.ru> Co-authored-by: BMFH <bogner85@mail.ru> (cherry picked from commit 135aef3)
64 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we assigned kerberos user name directly to the flask user,
but this had no chance to work because we expect FAB user there and
our security code crash with 'str' has no attribute 'perms'.
This PR uses Kerberos username (including the Kerberos realm) to
retrieve the user from the security manager. This means that
the user name has to have the form of
user_name@KERBEROS_REALM
.The reason why we are not using email (despite similarities of
the realm and domain name is that those are often different. Email
domain names have often nothing to do the with the realms within
organisations, and it seems safer to put fully qualified names
including the realm in order to uniquely identify the users in
case the organisation uses more than one REALM.
Fixes: #28919
^ 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.