authn: name claim declarations by yaml key in Config.Validate errors

Aperta
#341 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sthanikan2000 ci sta già lavorando.

Dal 23/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Priority/Low Type/Improvement
Current Limitation

authn.Config.Validate names a bad claim declaration by its Go field path, while the rest of the same function names the yaml key. For example, with userClaims.optional: [scope] it returns:

UserClaims.Optional declares claim(s) [scope] that authn already binds (fixed schema: client_id, grant_type, scope, roles, and the JWT registered claims)

but a missing audience returns audience is required, and Config carries yaml tags (userClaims, clientClaims) so a host can embed it in its own config file. A deployer who wrote userClaims.optional is shown UserClaims.Optional, a different spelling from the key they edited, and one that differs from every other message Validate returns.

The names come from the what strings in Config.Validate (config.go): "UserClaims.Optional", "UserClaims.Required", "ClientClaims.Optional" and "ClientClaims.Required".

Suggested Improvement

Use the yaml keys in those four strings: userClaims.optional, userClaims.required, clientClaims.optional and clientClaims.required, so claim errors read like the other Validate errors. The labels on the option path (WithUserClaims optional, ...) already name that API and stay as they are.

This only changes error text. A host that maps Config onto its own, differently named keys would still need to translate the message itself.

Version

github.com/OpenNSW/core/authn v0.4.0

Additional Context

Low priority; nothing is blocked. It came up in OpenNSW/nsw-srilanka#709, which lets a deployment list extra token claims in its own config and passes them to core/authn, so the core message reaches deployers unchanged.

Lingua principale
Go
Stelle
6
Fork
8
Merge medio
21h 36m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenNSW/core

Tutte le issue di OpenNSW/core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.