feat: Keycloak: Move camera authentication to Keycloak
Maintainers usually reply within 7 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- api, authentication, backend
Research direction
Start with the dependent Keycloak authentication work in #698, then trace the API's POST /cameras/{id}/token and get_jwt paths. Review pyroclient's current static-token handling and the Keycloak test realm in pyro-envdev#45. Done means Keycloak is the sole issuer after migration, clients can refresh credentials reliably, and legacy support is removed only after rollout.
Written by the indexing model from the issue text.
Description
Part of the epic pyronear/roadmap#23 (Keycloak).
Context & objective
Depends on #698 (Keycloak user authentication). Once users are on Keycloak, cameras are the last clients using API-issued JWTs.
Goal: Keycloak becomes the only token issuer. The API only verifies tokens and no longer issues any.
What is done currently
- An admin creates a camera token via
POST /cameras/{id}/token: API-signed JWT (JWT_SECRET),camerascope, valid 1 year. pyro-enginestores one static token per camera and passes it topyroclient. There is no login and no refresh.- No way to revoke a single camera token.
What has to be done
- Keycloak: one confidential client per camera (client credentials flow), with a
camerarole and claimscamera_id+organization_id. - API: remove
create_access_token,JWT_SECRET/JWT_*settings,POST /cameras/{id}/tokenand the API-issuer path inget_jwt. Keycloak token verification is the only path left. - pyroclient: authenticate with
client_id/client_secret, cache the token and refresh it before expiry (and on 401). - pyro-engine: switch the credentials from a token to
client_id/client_secret(companion issue in pyro-engine). - Throwaway script to create the Keycloak clients for existing cameras.
Technical considerations
- Field connectivity is intermittent (4G): use a reasonably long token lifetime, and make sure a failed refresh doesn't block local detection (retry, keep queueing).
- Rollout: optin to discuss : devices are updated progressively, so the API has to accept both issuers until the whole fleet is migrated. Only then remove the legacy path.
- Provisioning a new camera = creating the camera in the API + its client in Keycloak. Manual for now, to be automated later.
- Dev & e2e: pyro-envdev Keycloak (pyronear/pyro-envdev#45), with a realm containing test camera clients.
- Dominant language
- Python
- Stars
- 31
- Forks
- 15
- Avg merge
- 7d 18h
- Merged PRs (30d)
- 17
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyronear/pyro-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 7 days
-
endpoint: detections type: fix
Difficulty 4/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 7 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 7 days
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 7 days
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Maintainers usually reply within 7 days
All issues in pyronear/pyro-api
Similar issues
-
area: ci enhancement perceived difficulty: 1
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Nitjsefnie-Harness-Commons/daedalus#1826 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vllm-project/vllm-sail#398 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
DiamondLightSource/sm-bluesky#476 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100