Skip to content

feat(settings): add persistent access token management - #1007

Open
elig-45 wants to merge 2 commits into
gramps-project:mainfrom
elig-45:anniversary-ics-web
Open

feat(settings): add persistent access token management#1007
elig-45 wants to merge 2 commits into
gramps-project:mainfrom
elig-45:anniversary-ics-web

Conversation

@elig-45

@elig-45 elig-45 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Add centralized persistent access token management under Settings > User > Account.

This uses the scoped persistent token infrastructure introduced in gramps-web-api#790.

What's included

  • Show Access tokens under the existing Account section with Gramps Web API 3.18 or newer.
  • Maintain an extensible frontend registry of known token scopes.
  • Load each scope status using:
    • GET /api/users/-/access-tokens/<scope>/
  • List active tokens only.
  • Show a simple empty state when no tokens are active.
  • Keep loading and unavailable states outside the token list, with a retry action for failed status requests.
  • Allow active tokens to be revoked after confirmation using:
    • DELETE /api/users/-/access-tokens/<scope>/
  • Preserve an active token row and allow another attempt when revocation fails.

Security

  • The UI handles token status and revocation only.
  • Raw token values are never requested, displayed, or stored.

Testing

Added unit coverage for:

  • API version compatibility
  • Placement under the Account section
  • Active-only rendering and the empty state
  • Loading, failure, and retry behavior
  • Revocation confirmation and cancellation
  • Successful and failed revocation

Related

@elig-45

elig-45 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Keeping this PR in draft and on hold.

Backend is split in gramps-web-api:

Once those backend PRs are reviewed/merged, I will update/rebase this frontend PR against the final backend API.

@elig-45

elig-45 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Draft note:
The API endpoints currently listed here still reflect the previous shape.
No need to update this now while this PR is in draft, since backend token endpoint structure may still change during review of gramps-web-api#790.

We'll align this PR once backend API shape is finalized.

@elig-45
elig-45 force-pushed the anniversary-ics-web branch from a3e0d6e to eedeeda Compare July 23, 2026 18:45
@elig-45

elig-45 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

I rebased this frontend branch on current main and aligned it with the finalized backend API from gramps-web-api#790 and #792.
token management now uses /api/users/-/access-tokens/anniversaries_ics/
the UI only exposes the complete ICS subscription URL, never the raw token separately
generated links point to /api/anniversaries.ics?token=...
existing subscriptions can be regenerated or revoked

This completes the frontend implementation step described in gramps-web#683.

@DavidMStraub

Copy link
Copy Markdown
Member

Thanks for this!

But since we implement the generic long-lived token infrastructure in the backend (but not the ICS subscription yet), I'd like to have a centralized place in the settings where tokens can be revoked, before we implement the ICS subcription in the backend.

Would you be willing to implement this?

Sorry if my comment gramps-project/gramps-web-api#792 (comment) was misleading.

I think we can merge the entire feature in the next couple of weeks 🚀

@elig-45

elig-45 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

I'm on it ;)

@elig-45
elig-45 force-pushed the anniversary-ics-web branch from eedeeda to 0b49a39 Compare July 28, 2026 02:18
@elig-45

elig-45 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

I rebuilt this PR as the centralized persistent token management UI requested.

It now provides token status and confirmed revocation under Settings > User, without retrieving or storing raw token values. The previous ICS generation and subscription controls have been removed from this PR and will be submitted in a next one.

@elig-45 elig-45 changed the title feat(settings): add ICS anniversary subscription controls feat(settings): add persistent access token management Jul 28, 2026
@DavidMStraub
DavidMStraub requested a review from Copilot July 28, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Settings > User > Access tokens section to manage scoped persistent access tokens (API-backed feature gated on Gramps Web API >= 3.18), allowing users to review scope status and revoke active tokens without ever handling raw token values.

Changes:

  • Introduces a small frontend registry of known persistent token scopes and a UI to show per-scope status (Active/Inactive/Loading/Unavailable) with error isolation and retry.
  • Adds revocation flow with confirmation dialog, scoped API calls (GET status, DELETE revoke), and notifications/errors.
  • Adds unit tests covering version gating, status loading/error handling, revocation confirmation paths, and ensuring raw tokens / generation helpers are not exposed.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/views/GrampsjsViewSettingsUser.js Adds token-scope registry, status fetching, revoke dialog + handlers, and gated rendering in the User settings view.
lang/en.json Adds frontend i18n strings for the new Access tokens UI.
test/unit/settings-user-access-tokens.test.js Adds unit coverage for token status, retries, revocation flows, and security constraints (no raw token handling).

@DavidMStraub

Copy link
Copy Markdown
Member

Thanks!

Feedback:

  • I don't want to have a separate section for this in user settings. It fits perfectly under "Profile info, credentials, and account security". Make it an h3 under that.
  • The UI is currently this:
grafik

I find this misleading. Even if we had already shipped the ICS feature, a user who never encountered that feature, or does not intend to use it, will be confused by seeing a token listed there, which they never created, and which is shown as "inactive" with a disabled "revoke" button.

My suggestion: only show active tokens, ever. If none are there, just say so. No disabled button states.

@elig-45

elig-45 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Ah ok my bad I didn't understand correctly.
I corrected this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/views/GrampsjsViewSettingsUser.js:245

  • When the settings view becomes inactive (active=false) while the revocation dialog is open, _pendingAccessTokenScope is never cleared. This can cause the dialog to reappear unexpectedly when navigating back to the view (since rendering is gated by shouldUpdate() and the state persists). Clearing _pendingAccessTokenScope when active flips to false avoids stale dialogs across navigation.
    if (this.active && changed.has('active')) {
      this._loadAccessTokenStatusesIfNeeded(true)
    } else if (this.active && changed.has('appState')) {
      this._loadAccessTokenStatusesIfNeeded()
    }

src/views/GrampsjsViewSettingsUser.js:593

  • The revocation dialog only listens for cancel, but Material md-dialog can close via other paths (and other dialogs in this repo reset state via @closed, e.g. src/components/GrampsjsTagsManager.js:144-148). Adding an @closed handler ensures _pendingAccessTokenScope is cleared whenever the dialog closes.
      <md-dialog open @cancel="${this._cancelAccessTokenRevocation}">

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.

3 participants