Skip to content
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

Add groups to users automatically via Oauth #1677 #2159

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

khanfarr
Copy link

@khanfarr khanfarr commented Apr 16, 2024

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:

  1. Updated GroupAwareAuthenticationPolicy
  • Enhanced the unauthenticated_userid method to parse the JWT and extract user and group information.
  • Modified the effective_principals method to dynamically add user-specific and group-specific principals based on the extracted data.
  1. Testing
  • added comprehensive tests in test_authentication.py to ensure the functionality works as expected under various scenarios:
  • Valid tokens with correct group claims.
  • Expired tokens and malformed tokens to test error handling.
  • Tokens without group claims to ensure fallback behavior remains correct.

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!

Introduces the extraction of group claims from JWTs within the authentication middleware. This will enable automatic OAuth group assignment to user sessions
@khanfarr khanfarr marked this pull request as ready for review April 24, 2024 03:14
@khanfarr khanfarr marked this pull request as draft April 28, 2024 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant