-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor: AUTH_LDAP/AUTH_OAUTH + implement role mapping #1374
Conversation
f73929d
to
99d5cda
Compare
@dpgaspar can you please review this? |
99d5cda
to
fe5670c
Compare
bb7d973
to
021e142
Compare
I have accidentally introduce a behaviour change for LDAP servers which bind without a search account, I will make some changes tomorrow. (+ I need to fix that failing test) |
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.
Did a first pass, but I do not feel comfortable on merging this without more tests, that would cover the new config keys and feature
@thesuperzapper, I expect to release FAB major 3 soon, would love to get this one in. |
@dpgaspar yeah, I will pick this up again, got a bit busy over the last few weeks. What is your timeline for 3? |
@thesuperzapper, gentle bump. Also happy to help get some test coverage on this. FAB 3 has already been released, so we missed that boat. |
@jedcunningham, would welcome some help on the testing side. I can pretty easily address the requested changes above. |
@thesuperzapper, I've actually got pretty close to complete coverage on the ldapauth side of things at this point and have addressed some of the concerns raised above. I don't have an easy way to test the oauth side out though. Let me get my stuff through my $works legal and I'll get my changes out. |
@thesuperzapper, sorry for the delay... https://github.com/jedcunningham/Flask-AppBuilder/commits/role_binding I had to refactor some of the ldap portion to get it matching the existing behavior, which probably undid some of the fixes for #770 and #1123. It might be worth handling those separately though, as at least for me, it's easier to reason about and review changes that aren't all mixed together 🤷♂️. I'm also sending you a DM on the Airflow slack. It might be easier (and less noisy for others) to coordinate there. |
@thesuperzapper we’d love to make use of this functionality in our project. Is there anything we can do to help get this ready for approval faster? |
@accorvin we are currently working on it, so expect an update in a week or so. |
@thesuperzapper we require this functionality in our project as well. Any idea on when this will be released or how we can help speed this up? |
@dpgaspar yes, please |
Any updates? |
@dpgaspar FYI, the only failing check is a code coverage one (it dropped below 72.75%), but I am not sure its correctly detecting the coverage. Regardless, I would love to hear your thoughts on the changes. |
@dpgaspar do you know when you will get a chance to review this? This PR is pretty important for Airflow 2.0, given we now exclusively use FAB. |
@thesuperzapper awesome work, this looks pretty good! going to take it for a test run today, if all good I think it should be ready to merge Note: not a blocker but would be great if you could add some missing type annotations Released this out of this PR: https://pypi.org/project/Flask-AppBuilder/3.2.0rc1/ for easier testing |
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.
After testing found the email field user registration problem
flask_appbuilder/security/manager.py
Outdated
user_attributes, self.auth_ldap_lastname_field, "" | ||
), | ||
email=self.ldap_extract( | ||
user_attributes, self.auth_ldap_email_field, "" |
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.
we should add f"{username}@email.notfound"
or similar, if an LDAP server does not have their email fields populated, it's impossible to register multiple users this way since it hits the email DB unique constraint
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.
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.
done @dpgaspar
@dpgaspar should be ready to review again |
Any update on this? |
@dpgaspar anything more you want to change before we merge? |
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.
LGTM
@dpgaspar Do you know when will this feature be released? This PR is super helpful and will make ldap based rbac so much better 🥇 |
@msardana94 Planning to release next week |
@dpgaspar @thesuperzapper Is multiple role supported for |
And one more thing
Is OR AND condition supported ? |
@dpgaspar @thesuperzapper is this feature will be include in latest version of flask-appbuilder and do we have to use airflow 2.0.0 ? |
#is AUTH_ROLES_MAPPING working for you to authenticate different users from LDAP groups ? |
@Asturias-sam currently, we do not support OR/AND semantics in But most people can achieve the same outcome by creating nested groups in your LDAP/AD itself, however, I can see a need for this in OAUTH (where making groups may be harder). We could allow python functions as the keys of def is_fab_user(user_role_keys: Set[str]) -> bool:
is_users_1 = "cn=fab_users_1,ou=groups,dc=example,dc=com" in user_role_keys
is_users_2 = "cn=fab_users_2,ou=groups,dc=example,dc=com" in user_role_keys
return is_users_1 and is_users_2
AUTH_ROLES_MAPPING = {
is_fab_user: ["User"],
"cn=Admin,ou=groups,dc=example,dc=com": ["Admin"],
} @Asturias-sam if you want this feature, please raise and issue, and tag me in it (probably link to this comment also) |
This PR is a significant refactor for AUTH_LDAP and AUTH_OAUTH.
Aside adding significant unit testing, and resolving many issues, it implements a feature with
AUTH_ROLES_MAPPING
to allow mapping LDAP/OAUTH groups to FAB Roles.For more information, please see the updated
docs/security.rst
Resolves:
Superseeds these PRs: