Skip to content

feat(auth): enforce one session per org name#602

Merged
platinummonkey merged 4 commits into
DataDog:mainfrom
srosenthal-dd:stephen.rosenthal/pup-session-one-per-name
Jun 23, 2026
Merged

feat(auth): enforce one session per org name#602
platinummonkey merged 4 commits into
DataDog:mainfrom
srosenthal-dd:stephen.rosenthal/pup-session-one-per-name

Conversation

@srosenthal-dd

@srosenthal-dd srosenthal-dd commented Jun 18, 2026

Copy link
Copy Markdown
Member

Depends on #600 (merge that first -- they both touch README.md and will conflict).

Summary

  • Enforces one-session-per-name invariant for named sessions, extending the single-slot guarantee that already applies to unnamed sessions (from fix(auth): resolve default-session site for bare commands (#592) #596)
  • save_session: deduplicates by org name alone instead of (site, org)
  • find_session: looks up by org alone, drops the now-redundant site parameter
  • find_session_site: simplified -- no ambiguity path possible
  • remove_session: filters by org alone
  • README: removes the named-session multi-site disambiguation paragraph (no longer applicable)

@datadog-datadog-prod-us1

This comment has been minimized.

Previously the session registry key was (site, org), so the same org
name could appear on multiple sites as separate entries. This caused
ambiguity in find_session_site when a user logged in as the same name
on datadoghq.com and datadoghq.eu.

The unnamed (default) session already had a single-slot invariant
enforced by prune_other_default_sessions. This extends the same
invariant to named sessions: save_session now deduplicates on org
alone, so logging in as --org foo on a new site silently replaces the
prior entry rather than accumulating a second one.

find_session now looks up by org alone (no site parameter), and
find_session_site is simplified to a single .find() since the registry
is guaranteed to hold at most one entry per name.

Legacy sessions.json files with duplicate named-org rows self-heal on
the next pup auth login for that org name.
@srosenthal-dd srosenthal-dd force-pushed the stephen.rosenthal/pup-session-one-per-name branch from 3a27245 to 406b9ad Compare June 18, 2026 15:41
@platinummonkey

Copy link
Copy Markdown
Collaborator

would there be a case where someone wants myorg-readonly and myorg-readwrite and myorg-workflow-action-run-only setups?

@srosenthal-dd

srosenthal-dd commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

would there be a case where someone wants myorg-readonly and myorg-readwrite and myorg-workflow-action-run-only setups?

@platinummonkey we should still be able to do that!

Datadog "org" = an account
pup "--org" == a named session (maybe should have picked a different word)

This PR makes it so pup doesn't reuse the same name for multiple sessions. Some users might have two "prod" named sessions for two different sites, and now they'll have to use separate names like --org prod-us and --org prod-eu. The benefit is less ambiguity.

It's still possible to have multiple pup named-sessions (--orgs) pointing to the same Datadog org, potentially with different scopes. I tested with a --org ddstaging and --org ddstaging-ro, where one can create a notebook and the other can't. They'll just have to use different names.

@srosenthal-dd srosenthal-dd marked this pull request as ready for review June 18, 2026 16:14
@srosenthal-dd srosenthal-dd requested a review from a team as a code owner June 18, 2026 16:14
platinummonkey
platinummonkey previously approved these changes Jun 18, 2026
@srosenthal-dd srosenthal-dd dismissed platinummonkey’s stale review June 18, 2026 16:59

The merge-base changed after approval.

platinummonkey
platinummonkey previously approved these changes Jun 22, 2026
@srosenthal-dd srosenthal-dd dismissed platinummonkey’s stale review June 22, 2026 13:07

The merge-base changed after approval.

platinummonkey
platinummonkey previously approved these changes Jun 22, 2026
@srosenthal-dd srosenthal-dd dismissed platinummonkey’s stale review June 22, 2026 14:05

The merge-base changed after approval.

platinummonkey
platinummonkey previously approved these changes Jun 23, 2026
@srosenthal-dd srosenthal-dd dismissed platinummonkey’s stale review June 23, 2026 11:51

The merge-base changed after approval.

@srosenthal-dd srosenthal-dd reopened this Jun 23, 2026
@platinummonkey platinummonkey merged commit 27b64a6 into DataDog:main Jun 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants