jupyterhub / oauthenticator

OAuth + JupyterHub Authenticator = OAuthenticator
https://oauthenticator.readthedocs.io
BSD 3-Clause "New" or "Revised" License
415 stars 366 forks source link

`allow_all` doc string is incomplete / wrong #723

Closed yuvipanda closed 9 months ago

yuvipanda commented 10 months ago

Bug description

The allow_all config currently is documented as:

Allow all authenticated users to login.

However, this is not true because in many cases other authorization steps do step in. But not all authorization steps.

Currently, based on the code in https://github.com/jupyterhub/oauthenticator/blob/5667bf15f8e1dead29c32cc0886146d6ddb835ec/oauthenticator/oauth2.py#L1015, setting allow_all to True ignores the following other config:

  1. allowed_users is fully ignored
  2. Setting admin in the auth_model is ignored

But anything in subclasses is not ignored:

  1. GitHubOAuthenticator's allowed_organizations is not ignored
  2. Generic's allowed_groups is not ignored
  3. etc

I think this is pretty confusing.

Suggested change

  1. We should augment the currently sparse allow_all doc with more information on what exactly it is doing.
  2. If it's intentional that allowed_users is ignored if allowed_all is set, we should add a validation that marks them as mutually exclusive.
yuvipanda commented 10 months ago

I just tested this config:

        GitHubOAuthenticator:
          allow_all: true
          allowed_organizations:
            - test:test

And despite the fact I'm not a member of that org, I was allowed in. That's actually what I was expecting - all other variants are ignored.

So in this case, it actually doesn't matter that allowed_organizations is set. So I think it's the same that allowed_users may be set, and just as ignored.

I understand this better now, and it actually does work as I think it should.

yuvipanda commented 10 months ago

I think the problem was just me misunderstanding something https://github.com/jupyterhub/oauthenticator/pull/719#issuecomment-1911166511. Sorry for the noise everyone.

manics commented 10 months ago

I'm reopening this since you've brought up a valid point. Although the docstring for allow_all may be technically correct it's unclear how allow_all fits in to the whole authorisation chain. For example, JupyterHub has blocked_users so clearly there has to be a priority amongst these different conditions.

I think we should

consideRatio commented 10 months ago

There are several config options allowing a user access, but they are independent from each other so that the ordering is irrelevant.

If a user is allowed by being listed in allowed_users, admin_users, being an existing user and allow_existing_users is true, or by being part of a allowed_organization, or by simply being any authenticated user via allow_all.

From https://oauthenticator.readthedocs.io/en/stable/reference/changelog.html and the 16.0.0 entry: Screenshot_20240126-023624

Its quite simple to describe how things are in oauthenticator 16 i think:

So briefly to be authorized, you have to:

With this said, i don't think allow_all should be updated specifically as this issues title suggests - but yes, clarifying the requirement of being authorized further could be relevant somewhere if this config isn't intuitive enough.

consideRatio commented 9 months ago

I'll go for a close on this issue, I've opened https://github.com/jupyterhub/oauthenticator/issues/727 to track what I think is what you are asking for @manics.