403 : Forbidden

I am working with jupyterhub and I configured authentication class as ( c.JupyterHub.authenticator_class = ‘oauthenticator.gitlab.LocalGitLabOAuthenticator’) but when I am trying to login remote user its throwing an below error

403 : Forbidden

Sorry, you are not currently authorized to use this hub. Please contact the hub administrator.

You need to post more details like hub logs and other relevant config. It is very hard to guess the issues from this limited information.

Hi mahendrapaipuri Below are the logs

[W 2023-10-31 12:08:11.987 JupyterHub auth:532] User ‘harshal.raghatate.work’ not allowed.
[W 2023-10-31 12:08:11.987 JupyterHub base:825] Failed login for unknown user
[W 2023-10-31 12:08:11.987 JupyterHub web:1869] 403 GET /hub/oauth_callback?code=44937f6e6c8e2a514cff18a9f5d9c58626c927708aa75d0a46bd9f6358e8588b&state=eyJzdGF0ZV9pZCI6ICIyNTE2MjNiZTdiYTk0YWZiOGRkNTFhNGFkOGYzNDk0ZCJ9 (110.224.115.111): Sorry, you are not currently authorized to use this hub. Please contact the hub administrator.
[W 2023-10-31 12:08:11.988 JupyterHub log:186] 403 GET /hub/oauth_callback?code=[secret]&state=[secret] (@110.224.115.111) 801.62ms

Can you try to set config c.Authenticator.allowed_users = {'harshal.raghatate.work'}? If it works, either you need to add all the users that need to that set or use an empty set to allow all the users.

Hi, this is working by hardcoding but its quite hard to manage every user details in jupyter_config.py

If you use c.Authenticator.allowed_users ={}, it will allow all users. If you need a more fine grained access control, you will have to override check_allowed method to implement your custom logic

Hi, If I enable c.Authenticator.allowed_users ={} then its throwing an below error
File “/datadrive/miniconda3/lib/python3.11/site-packages/traitlets/traitlets.py”, line 2314, in validate
self.error(obj, value)
File “/datadrive/miniconda3/lib/python3.11/site-packages/traitlets/traitlets.py”, line 833, in error
raise TraitError(e)
traitlets.traitlets.TraitError: The ‘allowed_users’ trait of a LocalGitLabOAuthenticator instance expected a set, not the dict {}.

My bad, it should be a set as the error suggests. So, it should b e c.Authenticator.allowed_users = set()

Still I am getting the same error
[W 2023-10-31 13:16:46.790 JupyterHub auth:532] User ‘priya.sachan.work’ not allowed.
[W 2023-10-31 13:16:46.790 JupyterHub base:825] Failed login for unknown user
[W 2023-10-31 13:16:46.790 JupyterHub web:1869] 403 GET /hub/oauth_callback?code=215967a1567c789eadbf73b94769330ef7d1e6afe6d8cababbb7195239572426&state=eyJzdGF0ZV9pZCI6ICIzNjRiYjA0YjE0MDU0OWQ5YmJlYTM5MWZlMDYxMTFlZiJ9 (110.224.118.60): Sorry, you are not currently authorized to use this hub. Please contact the hub administrator.

Seems like OAuthenticator has one more config parameter to control this beahviour. You need to set c.OAuthenticator.allow_all = True

Hi @mahendrapaipuri Thanks for the help, it’s working now

1 Like