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

Open
#341 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@sthanikan2000 is already working on this.

Since Oct 23, 2026.

Assessment

This issue has not been assessed yet.

Description

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.

Dominant language
Go
Stars
6
Forks
8
Avg merge
21h 36m
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenNSW/core

All issues in OpenNSW/core

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.