feat: Keycloak: Move camera authentication to Keycloak

オープン
#699 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
fastapi, python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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), camera scope, valid 1 year.
  • pyro-engine stores one static token per camera and passes it to pyroclient. 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 camera role and claims camera_id + organization_id.
  • API: remove create_access_token, JWT_SECRET / JWT_* settings, POST /cameras/{id}/token and the API-issuer path in get_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.
主要言語
Python
スター
30
フォーク
15
平均マージ
4日 15時間
マージ済み PR(30日)
16

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pyronear/pyro-api のほかの issue

pyronear/pyro-api の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。