Skip to content

chore: token policies persisted in DB#967

Draft
Stellatsuu wants to merge 13 commits into
DIRACGrid:mainfrom
Stellatsuu:token-policies
Draft

chore: token policies persisted in DB#967
Stellatsuu wants to merge 13 commits into
DIRACGrid:mainfrom
Stellatsuu:token-policies

Conversation

@Stellatsuu

@Stellatsuu Stellatsuu commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes: #524

Changes:

  • Moved the dirac_policies from TokenPayload to RefreshTokensPayload and AccessTokenPayload.
    Later, this should be removed from RefreshTokensPayload.

  • RefreshTokens now has a policies column.
    Manual updates to the already existing DBTable is needed: ALTER TABLE RefreshTokens ADD COLUMN Policies JSON. It should add NULL by default for existing values.

  • Policies are added from all_access_policies in the exchange_token function if no policies were found in the DB (e.g, new RefreshToken). Otherwise, they are taken from the DB to create a new AccessTokenPayload.

  • mint_token function doesn't need to enrich the token anymore since the payloads already have the policies inside them, from exchange_token function.

  • enrich_token function now takes only the AccessTokenPayload and returns one dict with the policies values.

@Stellatsuu Stellatsuu requested review from aldbr and chaen July 2, 2026 11:45
@Stellatsuu Stellatsuu self-assigned this Jul 2, 2026
@fstagni

fstagni commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hi, can you resolve the conflicts?

@read-the-docs-community

read-the-docs-community Bot commented Jul 6, 2026

Copy link
Copy Markdown

@aldbr

aldbr commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Hi @Stellatsuu, thanks for the fast update 🙂

We have discussed it among the maintainers and we actually would like to hold that PR for now. As it includes DB changes, we see it as a good opportunity to leverage Alembic first.

We currently have no migration mechanism and we are close to have multiple installations running diracx (e.g. you are already running it in certification) so it would be easier to have Alembic doing the job.

I will open a new issue for Alembic and your work will be held until it's done, and you will just have to rebase your PR and add the alembic script for the migration basically.

What do you think?

@Stellatsuu

Copy link
Copy Markdown
Contributor Author

Hi @aldbr, no problem for me :)

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.

extra token information coming from policies are not persisted in the refreshtoken DB

3 participants