AzureADAzureAdOAuthenticator

Hi

I am having issues while setting JupyterHub to be used with AzureAdAuthenticator.
When I set AzureAd to manage my groups and define the post_hook, nothing happens. There must be something wrong but I can not figure it out.
¿Could you help me, please?
This is my config:

from oauthenticator.azuread import LocalAzureAdOAuthenticator, AzureAdOAuthenticator

class MyAzureADAuthenticator(LocalAzureAdOAuthenticator):
def normalize_username(self, username):
logging.info(‘DEBUG>>>>> inside normalize_username()…: ’ , str(username))
return username.lower().split(’@')[0]

c.JupyterHub.authenticator_class = MyAzureADAuthenticator
c.Authenticator.manage_groups = True
def my_hook(authenticator, handler, authentication):
print(“XXXXXXXXXXXXXXXXXXXXXXXXXX)”)
print(authentication)
print(“YYYYYYYYYYYYYYYYYYYYYYYYYYY)”)
print(“XXXXXXXXXXXXXXXXXXXXXXXXXXX)”)
print(authentication)
print(“YYYYYYYYYYYYYYYYYYYYYYYYYYY)”)
return authentication

c.Authenticator.post_auth_hook = my_hook

Hi! Have a look at

We’ll need more information, for example what does “nothing happens” mean? Is authentication failing completely? If you turn on debug logging what do you see? What behaviour are you expecting, and what are you observing?

I assume when you mean “nothing happens”, you are not seeing those print statements in your logs.

Could you try replacing print with authenticator.log.info and check your my_hook is being called or not?

Hi
Thank you so much for your help.
You are right, I wasnt specific enough.
I meant that the lines were not printed. I dont really know why. I used authenticator.log.info instead print, but nothing got printed.
In any case, I ended up printing in a file, and I was able to verify that the hooks where been called (what was my principal doubt)

1 Like

Generally, when you use authenticator.log.info they should be logged to your hub logs given that you are properly formatting the log lines to strings.