@hgdc/auth 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,31 @@ authComponent.registerRoutes(http, (ctx) => {
|
|
|
55
55
|
})
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## Clés JWKS statiques côté Convex
|
|
59
|
+
|
|
60
|
+
Chaque appel HTTP à Convex avec un jeton (le rendu serveur de TanStack Start, `fetchAuthQuery`) fait vérifier ce jeton par le backend Convex, qui ne le met jamais en cache. Avec `getAuthConfigProvider()` seul, il va chercher les clés à `<site>/api/auth/convex/jwks` **à chaque appel** : sous charge, cette adresse répond 429 et la page tombe en erreur. Les clés se donnent donc en dur, par la variable `JWKS` du déploiement Convex :
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
// convex/auth.config.ts
|
|
64
|
+
export default { providers: [getAuthConfigProvider({ jwks: process.env.JWKS })] } satisfies AuthConfig
|
|
65
|
+
|
|
66
|
+
// convex/auth.ts, dans les plugins
|
|
67
|
+
convex({ authConfig, jwks: process.env.JWKS })
|
|
68
|
+
|
|
69
|
+
// convex/authKeys.ts
|
|
70
|
+
export const latestJwks = internalAction({
|
|
71
|
+
args: {},
|
|
72
|
+
handler: async (ctx) => await createAuth(ctx).api.getLatestJwks(),
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
npx convex run authKeys:latestJwks --prod | npx convex env set JWKS --prod
|
|
78
|
+
npx convex deploy
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Sans `JWKS`, la configuration retombe sur l'adresse : un déploiement de développement marche sans rien poser. La variable contient la clé privée chiffrée : elle ne sort jamais du déploiement (ni affichée, ni copiée ailleurs). Après une rotation des clés, relancer les deux commandes.
|
|
82
|
+
|
|
58
83
|
## Entrée commune `/auth/hgdc`
|
|
59
84
|
|
|
60
85
|
Le menu « Produits » (`@hgdc/ui/account-menu`) envoie vers `https://<mot>.hgdc.ch/auth/hgdc`, pas vers la page d'accueil publique. Chaque produit monte cette route serveur, au même chemin :
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hgdc/auth",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Connexion HGDC : bouton « Se connecter avec HGDC », config better-auth et gardes Convex.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://github.com/hugogebel-boop/hgdc-kit/tree/main/packages/auth#readme",
|