Skip to content

v0.1.3 — OAuth2/OIDC authentication

Choose a tag to compare

@zombocoder zombocoder released this 12 Jul 14:29
· 27 commits to main since this release

Adds OAuth2/OIDC authentication for goboot APIs (#48, PR #49).

Runtime

  • Principal (subject/username/roles/scopes/claims) + WithPrincipal/PrincipalFrom context helpers.
  • Authenticator seam (request → Principal) with an AnonymousAuthenticator default.
  • RoleAuthorizer — enforces @Authorize/@RolesAllowed against the context principal (401 unauthenticated, 403 insufficient), per Mode.
  • Unauthenticated/Forbidden 401/403 error helpers.

HTTP wiring

Generated handlers now enforce route-level @Authorize: authenticate → WithPrincipal → authorize before binding. Secure by defaultDefaultHTTPHandlerDependencies ships AnonymousAuthenticator + RoleAuthorizer, so a secured route returns 401 until an authenticator is configured. Also fixes a latent bug where @Authorize on a @RestController method errored as a service proxy.

New module: adapters/oidc (adapters/oidc/v0.1.0)

A runtime.Authenticator over an OIDC provider (Keycloak): discovery + JWKS caching, signature/iss/aud/exp verification, claims → Principal (realm + client roles). Install: go get github.com/zombocoder/goboot/adapters/oidc@v0.1.0 (requires core v0.1.3).

Full test coverage incl. a mock-provider integration test and an httptest 401/403/200 e2e.