Hi, i want to change name by which pod gets spawned. Using AzureAd for authentication.I am following - Zero to JupyterHub with Kubernetes — Zero to JupyterHub with Kubernetes documentation
Admin has configured AzureAD to return below parameters-
resp.firstName = resp.data.givenName;
resp.lastName= resp.data.surname;
resp.email = resp.data.mail;
resp.userName = resp.data.mailNickname
Currently pod gets spawned using “firstName” + “lastName”. I want to change it to userName as it’s unique identifier in our organization. Is there a way to change this configuration.
manics
February 11, 2022, 6:36pm
2
It looks like the AzureAdOAuthenticator
has a username_claim
option:
config=True,
help="""Azure AD domain name string, e.g. My College""",
)
tenant_id = Unicode(config=True, help="The Azure Active Directory Tenant ID")
@default('tenant_id')
def _tenant_id_default(self):
return os.environ.get('AAD_TENANT_ID', '')
username_claim = Unicode(config=True)
@default('username_claim')
def _username_claim_default(self):
return 'name'
@default("authorize_url")
def _authorize_url_default(self):
return 'https://login.microsoftonline.com/{0}/oauth2/authorize'.format(
self.tenant_id
)
if PYJWT_2:
decoded = jwt.decode(
id_token,
options={"verify_signature": False},
audience=self.client_id,
)
else:
# pyjwt 1.x
decoded = jwt.decode(id_token, verify=False)
userdict = {"name": decoded[self.username_claim]}
userdict["auth_state"] = auth_state = {}
auth_state['access_token'] = access_token
# results in a decoded JWT for the user data
auth_state['user'] = decoded
return userdict
class LocalAzureAdOAuthenticator(LocalAuthenticator, AzureAdOAuthenticator):
"""A version that mixes in local system user creation"""
If that doesn’t work you can subclass and override the authenticate()
method to return a different username.
@manics Thank you, i will try this.