Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intégration backend avec Comptes DataPass #361

Closed
1 task done
florimondmanca opened this issue Aug 1, 2022 · 0 comments · Fixed by #365
Closed
1 task done

Intégration backend avec Comptes DataPass #361

florimondmanca opened this issue Aug 1, 2022 · 0 comments · Fixed by #365

Comments

@florimondmanca
Copy link
Collaborator

florimondmanca commented Aug 1, 2022

Refs:

Prérequis :

L'enregistrement et la connexion via son compte DataPass nécessite l'intégration technique avec ce système.

Pour cela, il faut :

  • Ajouter des boutons côté client qui appelleront un endpoint de proxy côté serveur d'API. Celui-ci devra appeler le Authorization Endpoint qui est : https://auth.api.gouv.fr/authorize
  • Implémenter un callback côté serveur d'API. Ce callback devra :
    • Appeler le TokenEndpoint, qui est https://auth.api.gouv.fr/token. On obtient ainsi un token puis le userinfo. Ce dernier contiendra : { email: str, organizations: []{id, siret} } (cf. doc api-auth).
    • Si un DataPassUser (cf. Transition vers DataPass #350) avec datapass_user.user.email == userinfo["email"] n'existe pas encore :
      • Créer le User avec les informations du userinfo, et lui assigner un DataPassUser (entité "marqueur" avec seulement un id).
    • Rediriger le navigateur vers une page frontend avec { organization_siret, email, role, api_token } en query parameters, ce qui permet au navigateur de stocker cela en localStorage puis de rediriger vers la page d'accueil connectée, comme pour le login classique actuel.
  • Une fois prêts, contacter l'équipe Comptes DataPass pour enregistrer le callback staging sur leur instance de test.

En prérequis, il faut faire passer les utilisateurs existants dans une table LegacyUser qui stockera leur password_hash, de sorte que User ne contienne plus que id, organization_siret, email, api_token, role.

Le backend d'authentification entre l'API et le front ne change pas : un utilisateur créé via Datapass aura aussi un api_token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant