Skip to content

feat(keycloak): make realm tokens usable by pyro-api and the scripts - #68

Draft
ThbltLmr wants to merge 8 commits into
feat/keycloakfrom
feat/keycloak-api-integration
Draft

ThbltLmr wants to merge 8 commits into
feat/keycloakfrom
feat/keycloak-api-integration

Conversation

@ThbltLmr

@ThbltLmr ThbltLmr commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Configures Keycloak for pyro-api and switches the init script and notebooks to a service account.

Based on #45. Requires pyronear/pyro-api#728. Platform demo uses pyronear/new-pyro-platform#295.

Platform login

keycloak-platform-demo.mp4

Session revocation

keycloak-api-demo.mp4

- pyro-api client scope: adds pyro-api to aud and the realm roles as a
  top-level roles claim
- pyro-organization claim renamed to organization_id, which avoids Keycloak's
  built-in Organizations claim
- new-pyro-platform gets both scopes by default
- pyro-api confidential client, used by the API to introspect tokens
- pyro-scripts service account (admin, org 1, 10h tokens) for the init script
  and notebooks
- test-admin user (admin, org 1)
…and scripts

- Keycloak leaves the tools profile, pins its issuer with KC_HOSTNAME and
  reports readiness from /health/ready
- pyro_api gets KEYCLOAK_ISSUER, the backchannel URL and the pyro-api client
  secret
- init_script and notebooks get the pyro-scripts credentials, with defaults
  for .env files created before Keycloak
The init script and notebooks use client credentials instead of logging in
with the superadmin password. The notebooks' legacy get_token stays for local
scripts while pyro-api still accepts API-issued user tokens.
@ThbltLmr
ThbltLmr added this pull request to stack #69 October 28, 2026 13:37
@ThbltLmr ThbltLmr changed the title feat/keycloak api integration feat(keycloak): make realm tokens usable by pyro-api and the scripts Oct 28, 2026
ThbltLmr and others added 3 commits October 29, 2026 20:24
Drop firstName and lastName from the realm user profile and from the
test users, so a new user is no longer asked for them at first login.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
fe51
fe51 previously approved these changes Nov 11, 2026

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

Tested locally against the feat/keycloak branch of pyro-api: make run-tools starts cleanly, the realm is imported, the init script completes, and the pyro-scripts service account as well as the four test users get working tokens. Organization isolation and role restrictions behave as expected with the platform branch running on port 5173.

I pushed one small commit (6106c6c): the user profile now only asks for an email. First name and last name are removed from the profile and from the test users, since we do not want to collect them. Checked on a fresh import: a new user is only asked for an email at first login.

One thing to keep in mind, not for this PR: make run works today only because the published front image still uses the old login form. The front container will need its Keycloak config once pyronear/new-pyro-platform#295 is released. Tracked in #71.

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

Re-approving after last commit !
Thanks a lot @ThbltLmr !

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