Skip to content

Feat/public client - #9

Merged
SebastienLaurent-CF merged 4 commits into
mainfrom
feat/public-client
Oct 20, 2026
Merged

SebastienLaurent-CF merged 4 commits into
mainfrom
feat/public-client

Conversation

@SebastienLaurent-CF

Copy link
Copy Markdown
Contributor

✨ Support public OIDC clients (no client secret)

Context

authk required a clientSecret, so it could not connect to a Keycloak client with
Client authentication: Off (public client).

Changes

  • clientSecret is now optional in the CUE schema (defaults to empty)
  • New authMethod: "none" value for public clients
  • When the client is public (authMethod: "none" or no secret), client_id is sent
    in the request body with no client_secret and no Authorization: Basic header
  • Token refresh works the same way for public clients
  • A public client cannot use the Client Credentials flow: authk now returns a clear
    error when no user credentials are configured, without calling the token endpoint
  • If authMethod: "none" is set while a secret is configured, the secret is ignored
    and a warning is logged

Configuration example

oidc: {
        issuerUrl:  "https://keycloak.example.com/realms/myrealm"
        clientId:   "my-public-client"
        authMethod: "none"
}
user: {
        username: "myuser"
        password: "mypassword"
}
Keycloak side: Client authentication off, Direct access grants enabled.

Tests

- Config: a config without a clientSecret loads
- OIDC client: the token request contains no secret and no Basic header,
  and client_credentials is refused for public clients
- go vet and go test ./... pass
- Not tested against a real Keycloak instance (only a mock server)

Notes

- Backward compatible: existing configurations with a secret are unchanged
- An empty secret (e.g. a ref+env:// that resolves to nothing) now switches to
  public client mode instead of failing
- Based on feat/id-token: merge that branch first, or retarget this MR

- Update configuration schema and Go structs to include idTokenKey
- Support saving ID tokens to .env files when configured
- Add --id-token flag to get command for direct output
- Add --id-token flag to inspect command for decoding
- Make ID token verification non-fatal to increase robustness
- Add unit tests for config loading and OIDC token handling
- Update README.md with new configuration options and flags
- Refactor `targets` schema to use `type` field instead of `idTokenKey`
- Update `inspect` command to intelligently resolve files and keys from the targets list
- Improve documentation for multiple target files and fix invalid examples in README
- Maintain backward compatibility for simple configuration via `tokenKey` and `idTokenKey`
- Make clientSecret optional and add "none" authMethod
- Send client_id in request body without secret for public clients
- Reject client_credentials flow when no secret is configured
- Add config and OIDC tests for public client behaviour
- Document Keycloak public client setup in README
@SebastienLaurent-CF
SebastienLaurent-CF merged commit f27caad into main Oct 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant