Add groups to users automatically via Oauth #1677 #2159
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.
Implement Automatic OAuth Group Assignment
Summary:
This pull request resolves the laborious and prone to error manual assignment of user groups from Azure AD, which was brought up in Issue #1677. The suggested modifications automate the process of grouping users according to OAuth group claims that Azure AD provides at the time of user login.
Issue:
As it is, the program needs human interaction to assign user groups when it comes to access controls and permission management. This manual procedure takes a long time and is prone to mistakes, which could result in operational inefficiencies and security threats.
Solution:
With the help of this PR, the aim is that Pyramid application's `GroupAwareAuthenticationPolicy' will now be improved to automatically identify groups based on OAuth tokens and associate them with user sessions. With the help of this feature, group assignment is managed precisely and dynamically, reflecting user rights set up in Azure AD.
Changes Made:
GroupAwareAuthenticationPolicy
unauthenticated_userid
method to parse the JWT and extract user and group information.effective_principals
method to dynamically add user-specific and group-specific principals based on the extracted data.test_authentication.py
to ensure the functionality works as expected under various scenarios:Next Steps:
This was for a class project, and definitely a WIP. I'm still a student and still learning so I'm happy to work on this on the side with some guidance as I'm sure there is a lot more work to be done here!