Skip to content

feat: detach tokens from extension versions - #2065

Open
cstamas wants to merge 18 commits into
eclipse-openvsx:mainfrom
cstamas:detach-token-from-extension-version
Open

feat: detach tokens from extension versions#2065
cstamas wants to merge 18 commits into
eclipse-openvsx:mainfrom
cstamas:detach-token-from-extension-version

Conversation

@cstamas

@cstamas cstamas commented Aug 12, 2026

Copy link
Copy Markdown
Member

Detach tokens from extension version, and allow to delete tokens, instead to preserve them as today.

Summary:

  • Added V1_73__ExtensionVersion_PublishedBy.sql migration: new published_by_id column (FK → user_data), backfilled from published_with_id, and changed the published_with_id FK to ON DELETE SET NULL.
  • Added publishedBy field to ExtensionVersion (mirroring the removedBy precedent), fixed a pre-existing bug where displayName was silently excluded from equals().
  • Repointed every read path (isVerified in LocalRegistryService/RelevanceService, toExtensionJson, OrphanNamespaceMigration) from getPublishedWith().getUser() to getPublishedBy().
  • Redesigned PublisherComplianceChecker to iterate by publisher instead of by token, so it stays correct once tokens are deleted.
  • Renamed/added/deleted JPA repository methods so no query joins through personal_access_token anymore.
  • Rewrote ~12 raw jOOQ joins across ExtensionVersionJooqRepository and AdminStatisticCalculationsRepository to join user_data directly via published_by_id.
  • Applied the migration through real Flyway (via a temporary git stash of the Java changes) and regenerated jOOQ code.
  • Updated all affected test fixtures and mocks.
  • Dropped stale FixTargetPlatformsJobRequestHandler and related classes, and now it opened way to truly delete tokens.
  • ExtensionVersion published_with_id fully removed.
  • Dropped single use of OTT token; only LTT and TPT are in use now. On flyway upgrade, delete non-LLT active=false tokens from DB table.
  • AccessTokenService drops on-time-used tokens, and cleaned up carry-around of PersonalAccessToken entity, service now returns UserData instead.
  • Verified: all tests pass.

So, now:

  • tokens are fully detached from extension versions and are deletable
  • use of OTT token that was quite "artificial" removed; along with OTT token type
  • on upgrade non-LLT inactive tokens are deleted
  • one time tokens on use are being deleted by AccessTokenService

As future plans may want us to delete tokens, instead accumulate them
and flag as deactivated.

Summary:
- Added V1_72__ExtensionVersion_PublishedBy.sql migration: new published_by_id column (FK → user_data), backfilled from published_with_id, and changed the published_with_id FK to ON DELETE SET NULL.
- Added publishedBy field to ExtensionVersion (mirroring the removedBy precedent), fixed a pre-existing bug where displayName was silently excluded from equals().
- Repointed every read path (isVerified in LocalRegistryService/RelevanceService, toExtensionJson, OrphanNamespaceMigration) from getPublishedWith().getUser() to getPublishedBy().
- Redesigned PublisherComplianceChecker to iterate by publisher instead of by token, so it stays correct once tokens are deleted.
- Renamed/added/deleted JPA repository methods so no query joins through personal_access_token anymore.
- Rewrote ~12 raw jOOQ joins across ExtensionVersionJooqRepository and AdminStatisticCalculationsRepository to join user_data directly via published_by_id.
- Applied the migration through real Flyway (via a temporary git stash of the Java changes) and regenerated jOOQ code.
- Updated all affected test fixtures and mocks.
- Verified: 841 unit tests + 922 integration tests (Testcontainers Postgres) all pass, and a manual SQL check confirms deleting a personal_access_token row no longer errors and correctly nulls published_with_id while leaving published_by_id intact.

Note: Known follow-up (out of scope): FixTargetPlatformsJobRequestHandler still republishes using the original token and would NPE if that token were ever deleted — this is a pre-existing gap in the publish pipeline's identity model, not introduced by this change.

@autumnfound autumnfound 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.

LGTM! Covers data migration, new field, and looks to cover all cases where the PAT was used in joins. We also have the index I'd expect for the field to keep the lookups zippy!

@cstamas
cstamas marked this pull request as ready for review August 14, 2026 12:13
gnugomez
gnugomez previously approved these changes Aug 18, 2026

@gnugomez gnugomez 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.

overall LGTM!

that's such a cleanup ◡̈

.collect(Collectors.groupingBy(PersonalAccessToken::getUser));
publisherTokens.keySet().forEach(user -> {
var accessTokens = publisherTokens.get(user);
if (!accessTokens.isEmpty() && !isCompliant(user)) {

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.

question: I think here we're now skipping an additional check that was made before where we would first check if the non compliant user had access tokens before performing the deactivation of its extensions.

Is that something we're doing on purpose?

Comment on lines +25 to +28
@Query(
"select distinct ev.publishedBy from ExtensionVersion ev where ev.active = true and ev.publishedBy is not null"
)
Streamable<UserData> findPublishers();

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.

now I understand where the check is!

Let's rename this to findActivePublishers or something like it, otherwise it's not completely clear that it would do that internally.

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.

maybe findPublishersWithActiveVersions would be more accurate, otherwise it implies that the publishers are the active subject

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call, renamed method to proposed one

@cstamas
cstamas requested a review from gnugomez August 19, 2026 12:39
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