Skip to content

deprecate hosted_domain in favor of restrict_hosted_domains, always apply strip_domain if True, clarify docstrings - #830

Merged
minrk merged 7 commits into
jupyterhub:mainfrom
minrk:docstring
Aug 28, 2026
Merged

deprecate hosted_domain in favor of restrict_hosted_domains, always apply strip_domain if True, clarify docstrings#830
minrk merged 7 commits into
jupyterhub:mainfrom
minrk:docstring

Conversation

@minrk

@minrk minrk commented Jul 15, 2026

Copy link
Copy Markdown
Member

related to #828 and the confusion that led to it

In discussing this, I also considered deprecating hosted_domain in favor of restrict_hosted_domains to be even clearer and disambiguate from the new allow_hosted_domains, but didn't take that step here, this is just the docstring.

@manics manics left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, and deprecating is also fine if you want since the configuration is pretty complex.

Is it intentional that strip_domain is ignored for everything other than hosted_domain

if self.strip_domain and user_info["domain"] in self.hosted_domain:
username = username.split("@")[0]

i.e. domains are never stripped if you're using allowed_domains?

Comment thread oauthenticator/google.py Outdated
@yuvipanda

Copy link
Copy Markdown
Collaborator

+1 for rename & deprecate, I think it makes this much clearer.

@minrk

minrk commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

Is it intentional that strip_domain is ignored for everything other than hosted_domain

I think that's a valid question, and I think the answer is "yes" that it's intentional, but that doesn't mean it has to be that way. It seems confusing that strip_domain has no effect when hosted_domain is not set, and potentially inconvenient if you want to use it for some reason. However, strip_domain is really only safe to use with hosted_domain (the restrictive one) of length exactly 1, it is not safe to use in any other configuration where usernames come from multiple @domain namespaces.

Co-authored-by: Yuvi <yuvipanda@gmail.com>
@minrk

minrk commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

What should the behavior of strip_domain be, and how should we migrate to it? This is a bit relevant to the deprecation of the name, since I'd like to not inherit the implicit behavior of the old name, if we can help it.

Here's what I think is the simplest:

  1. if strip_domain is true, it is applied to all accounts instead of just hosted_domain matches
  2. keep strip_domain = True default only when deprecated hosted_domain has length 1
  3. DO NOT default strip_domain = True in any other circumstances (i.e. don't inherit this conditional default in the new restrict_hosted_domains, and unconditional default=False when deprecated hosted_domain is dropped)

2 and 3 keep consistent current behavior and offer a smooth deprecation path, but 1 could be considered a breaking change, because if anyone had explicit strip_domain = True in a situation without hosted_domain set, it is a nonsensical (but safe!) no-op now (strip_domain = True + no hosted_domain is the same as strip_domain = False) , and becomes an actual sensible (but unsafe!) configuration with the change.

minrk added 4 commits July 15, 2026 17:35
and deprecate implicit strip_domain=True for single hosted_domain

strip_domain now ignores hosted_domain config and applies to all accounts
@minrk

minrk commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

This PR now reflects the above proposal - hosted_domain behavior is unchanged, but deprecated in favor of restrict_hosted_domains (always a list, doesn't need backward-compatibility shims for scalar string value). strip_domain now always strips the domain, regardless of hd and the value of of hosted_domain. It is only implicitly True when hosted_domain has exactly one value, otherwise it's must be set explicitly.

@minrk minrk changed the title try to clarify docstring for hosted_domain as a restriction, not allow config deprecate hosted_domain in favor of restrict_hosted_domains, always apply strip_domain if True, clarify docstrings Jul 16, 2026
@minrk minrk added the api-change (not necessarily breaking) changes to the api including deprecations label Jul 16, 2026
@minrk
minrk requested a review from manics August 27, 2026 16:54
Comment thread oauthenticator/google.py Outdated
Comment thread oauthenticator/google.py Outdated
Comment thread oauthenticator/google.py Outdated
docstrings

Co-authored-by: Simon Li <orpheus+devel@gmail.com>
@minrk
minrk merged commit 9af1663 into jupyterhub:main Aug 28, 2026
11 of 12 checks passed
@minrk
minrk deleted the docstring branch August 28, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change (not necessarily breaking) changes to the api including deprecations documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants