feat: Keycloak: Delegate user authentication to Keycloak (keep camera auth unchanged)
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start with get_jwt, get_current_user, and TokenPayload, then trace POST /login/creds and the protected user routes. Done means user tokens are validated through Keycloak while camera tokens and /cameras/{id}/token remain unchanged, migration and client updates are covered, and the users table and obsolete login routes are removed.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Part of the epic pyronear/roadmap#23 (Keycloak).
Context & objective
We want to move user authentication to a Keycloak service (SSO, user management, password policies, MFA…).
This will be done in steps: this issue covers user authentication only. Camera authentication must keep working as is.
Follow-up: camera authentication via Keycloak (#699 ).
What is done currently
- Users are stored in the
userstable (login, bcrypt password, role,organization_id). No other table references it. - Users log in via
POST /login/credsand receive an API-signed JWT (JWT_SECRET, HS256). - Routes are protected by
get_jwt/get_current_user, using scopes (admin,agent,user,camera) andorganization_idfrom the token. - Camera tokens are issued separately via
POST /cameras/{id}/token(same JWT mechanism,camerascope). GET /login/validateisn't used by any client.
What has to be done
- Validate Keycloak-issued tokens for user routes (realm JWKS) and map claims →
TokenPayload(sub, roles → scopes,organization_id). - Move users to Keycloak: role and
organization_idheld there (roles / attribute or group). - Throwaway script for a one-shot manual migration of existing users.
- Remove the
userstable,/usersroutes,/login/credsand/login/validate. - Keep API-issued camera tokens (
/cameras/{id}/token) working, with no change on devices. - Update clients currently using
/login/creds:new-pyro-platform,pyro-envdevinit scripts,pyro-annotatoringestion client (→ Keycloak service account).
Technical considerations
- During this step the API receives two kinds of tokens: Keycloak-signed (users, verified with the realm public keys) and API-signed (cameras, verified with
JWT_SECRET). Read the token'sissclaim to pick the right verification. TokenPayload.subis typedint, but a Keycloak usersubis a UUID string. Allow both, or split user and camera payloads (for cameras,subis still used ascamera_id, e.g. inposes.py).- User management (create, roles, org) is done in Keycloak from now on.
- Dev & e2e: rely on the Keycloak service in
pyro-envdev(pyronear/pyro-envdev#45). Keycloak deployment on prod is out of scope. - Keep the issuer dispatch simple and isolated, so that the API-issued path can be dropped once cameras are migrated.
- Lenguaje dominante
- Python
- Estrellas
- 30
- Forks
- 14
- Merge medio
- 3 d 18 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pyronear/pyro-api
-
type: feat
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Los mantenedores suelen responder en 2 días
-
Return the number of alerts per day over a periodPosiblemente ocupada @Majyles la tomó hace 4 días. Abiertotype: feat
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
pyronear/pyro-api#719 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
type: feat
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
-
Application metrics of the APIAbiertotype: feat
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 2 días
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 2 días
Todos los issues de pyronear/pyro-api
Issues similares
-
bug P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Toloka/tolokaforge#1947 ·
Los mantenedores suelen responder en 1 día
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpointsPosiblemente ocupada @balajiaru la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
pydot/pydot#601 · 4 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
letsencrypt/cp-cps#361 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100