-
Notifications
You must be signed in to change notification settings - Fork 367
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
[AzureAD] Add an implementation for Authenticator.authenticator_managed_groups=true #448
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,12 +32,20 @@ class AzureAdOAuthenticator(OAuthenticator): | |
def _tenant_id_default(self): | ||
return os.environ.get('AAD_TENANT_ID', '') | ||
|
||
username_claim = Unicode(config=True) | ||
username_claim = Unicode(config=True, help="Name of claim containing username") | ||
|
||
@default('username_claim') | ||
def _username_claim_default(self): | ||
return 'name' | ||
|
||
user_groups_claim = Unicode( | ||
config=True, help="Name of claim containing user group memberships" | ||
) | ||
|
||
@default('user_groups_claim') | ||
def _user_groups_claim_default(self): | ||
return 'groups' | ||
|
||
@default("authorize_url") | ||
def _authorize_url_default(self): | ||
return 'https://login.microsoftonline.com/{0}/oauth2/authorize'.format( | ||
|
@@ -96,6 +104,10 @@ async def authenticate(self, handler, data=None): | |
|
||
return userdict | ||
|
||
def load_user_groups(self, auth_state): | ||
auth_user_state = auth_state["auth_state"]["user"] | ||
return auth_user_state[self.user_groups_claim] | ||
Comment on lines
+107
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, what is calling this function? I find no reference to it in this repo or the Authenticator base class definition. Also I found no reference to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, this PR relies on jupyterhub/jupyterhub#3548. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @consideRatio - Unsure whether The functionality in this PR requires There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The In our case we extend our AAD's policy to make API calls to fetch and return group membership, as shown in this example: https://github.com/azure-ad-b2c/samples/tree/master/policies/rest-api-idp |
||
|
||
|
||
class LocalAzureAdOAuthenticator(LocalAuthenticator, AzureAdOAuthenticator): | ||
"""A version that mixes in local system user creation""" | ||
|
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.
If you have a default that is fixed like this, you can have it as the first argument passed to the
Unicode
constructor above instead.