Repository navigation
Add AUTH_TOKENS, per-account API token limits, and a main-site API token menu - #1164
Merged
Merged
Conversation
…ken menu Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Contributor
✅ Version Already UpdatedThis PR includes a manual version update to No automatic version bump needed. |
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
tariqksoliman
marked this pull request as ready for review
November 11, 2026 00:29
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
Contributor
🤖 Version Auto-BumpedThe version has been automatically incremented to This commit was added to your PR branch. When you merge this PR, the new version will be included. If you want a different version, update |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Purpose
Proposed Changes
[ADD]
AUTH_TOKENS=all|admins(defaultall).siteAccess.validate()stops startup on any other value.admins,policy.can(p, "tokens.create")is false unlesspolicy.isAdministrator(p), so/api/access/me,/api/longtermtoken/generateand the UI all follow the same rule.[CHANGE]
tokenPrincipalrefuses a token whose owner no longer holdstokens.create. The token isn't deleted, so it works again if the setting changes back. Its owner can still see and revoke it:/getand/clearnow only need a signed-in session with an account (own tokens; everyone's withtokens.manage). A former admin's tokens keep working, with only the access the account has now.[CHANGE]
/api/longtermtoken/generatelimits:neverand longer periods are refused.SELECT ... FOR UPDATE) inside a transaction, so concurrent requests can't get past the limit.replace_iddeletes the old token and creates the new one in the same transaction.[FIX] The name part of a token is capped at 32 characters (
MAX_LABEL), so names up to 64 characters no longer overflowtoken_prefix(varchar(64)). The full name is still stored.[CHANGE]
/api/longtermtoken/getalso returnsuser_id,limits(unlimited,max_tokens,max_period) andcan_createfor the UI.[CHANGE] The account menu is now React, under
UserInterface_/components/AccountMenu/:AccountMenuwrapsAccountSection(a profile header with the avatar, name and provider, thenApiTokensRowwhen signed in or a Sign in item for guests),ServicesSectionandSignOutItem. A shareduseLoginhook loadsLoginand followsmmgis:loginchange/mmgis:accountprovider.<button>items (Tab and Enter work), services show a status dot with their state, and only Connect is a filled button.TopBaropens it and owns whether it's open. It closes on an outside click or Escape.Connections_no longer draws the menu. It keeps the services list (newmenuServices()andtoolsUsing()exports), connect/disconnect, and the "connect first" cards inside tools.toggleMenu,closeMenuandavatarColorwere removed from it;avatarColormoved toAccountMenu/avatarColor.js.[ADD]
ApiTokensRowin the account menu, shown for accounts holdingtokens.create, or holding a paused token (marked Paused; the window then offers only Revoke). It loads after the menu opens and opens the newApiTokensmodal, which can:limits, read-only or all access, all or selected missions;ConfirmationModal).[ADD] Design-system
Menu(src/design-system/components/Menu), built on Base UI's menu: keyboard navigation, Escape closes only the menu, and focus goes back to the trigger.[CHANGE] Admins (
limits.unlimited) see a compact token list in a 520px window. Each token is one row with its name, access · missions · expiry, a status, and a ⋯ menu (Replace, Revoke/Remove). Clicking a row expands its prefix and details. Live tokens come first, soonest expiry first; expired tokens are dimmed at the bottom. Regular users keep the single card.[CHANGE] Token window layout ("polished" design):
[ADD] Design-system components built on
@base-ui/react:Radio: a list of choices one above the other, on Base UI radio-group;TextInput: on Base UIInput.The account menu and token modal use these together with the existing
Button,CheckboxandRadioGroup.[CHANGE] The segmented
RadioGroupis now built on Base UI radio-group, which gives it arrow-key navigation. Its default look is unchanged; a new opt-invariant="segmented"draws it as a full-width segmented control (used for the token window's expiry choice).[FIX]
Modalnow stacks modals in the order they open, not by id, and addsModal.top(). Before this,ConfirmationModal(id0) always drew behind any modal with a string id.ConfirmationModalnow closes on Escape when it's on top.[ADD]
AUTH_TOKENSinsample.envanddocs/pages/Setup/ENVs/ENVs.md. The account menu bullet indocs/pages/Contributing/Connections/Connections.mdnow mentions the token row.Issues
Modal.Testing
plugins/core/backend/LongTermToken/tests/user-tokens.spec.js(e2e,SITE_ACCESS=required AUTH_PROVIDERS=local) covers:/get;neverand anything over 90 days;replace_id, including another account's token id and a nonexistent id;never;/getand/clear;AUTH_TOKENS=admins(needsAUTH_TOKENS_SETUP_URLpointing at anallserver to make the token first): a paused token is listed withcan_create: false, doesn't authenticate, and its owner can revoke it.AUTH_TOKENSvalidation,can("tokens.create")underadmins, and refusing and re-enabling tokens intokenPrincipal.npx playwright test tests/unit/: 1778 passed. LongTermToken plugin tests: all passed (the olderlongtermtokens.spec.jsskipped itself).tests/e2e/auth/+tests/e2e/security/: 3 failures. The same 3 fail on unmodifieddevelopment(permission-matrixdataset listings,configure-exportviewing user,missions-viewingrestricted list).npm run buildcompiles. eslint shows no new problems; the oneno-restricted-globalserror inTopBar.jsxwas already there.development's jQuery menu. These matchdevelopment:SITE_ACCESS=public;AUTH_TOKENS=adminshiding the row for a regular user;SITE_ACCESS=optional; Tab and Enter reach and activate the token, Sign in and Sign out items.Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/86df24187c6a4fe7b88708c46ab61d0d
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/86df24187c6a4fe7b88708c46ab61d0d?variant=devin
Requested by: @tariqksoliman
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work