Documentation
¶
Overview ¶
Package oidcverify verifies OIDC ID tokens against admin-configured issuers.
The issuer a token is verified against always comes from stored configuration, never from the token itself. Discovery and JWKS fetches go through a transport that refuses to reach local or internal networks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnverifiedIssuer ¶
UnverifiedIssuer extracts the iss claim without checking the signature. It exists to select stored configuration; authorization must use Verify. Only compact JWTs are accepted so a flattened JWS cannot steer discovery.
func ValidateIssuerURL ¶
ValidateIssuerURL checks that raw is safe to store as a trust policy issuer: an https URL with a host and no credentials, query, or fragment, that does not address a private or internal network. allowInsecure permits http and local/internal hosts, for tests and local development.
Types ¶
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier verifies OIDC ID tokens.
Providers are cached per issuer: oidc.Provider owns a key set that caches JWKS and refreshes on an unknown kid, so constructing one per request would repeat discovery and throw away rotated keys.
func NewVerifier ¶
NewVerifier returns a verifier. allowInsecure permits issuers that are not on the public internet, for tests and local development.
func (*Verifier) Discover ¶
Discover confirms the issuer serves a discovery document whose issuer matches, and caches the provider. Call it when an issuer is configured so a typo fails the configuration request instead of the first token exchange.
func (*Verifier) Verify ¶
func (v *Verifier) Verify(ctx context.Context, rawToken, issuer, audience string) (map[string]any, error)
Verify checks the token's signature, issuer, audience, and time claims against the given issuer and audience, and returns the verified claims.
issuer and audience must come from stored configuration. The unverified iss claim is only safe for choosing which configuration to load.