Documentation
¶
Index ¶
- func AddApiKeyTransport(t http.RoundTripper) http.RoundTripper
- type CodeChallengeMethod
- type EntityStatement
- type Error
- type FederationEntity
- type FederationEntityMetadata
- type IdentityProviderInfo
- type Jwk
- type Jwks
- type KeyConfig
- type Metadata
- type OpenIDProviderMetadata
- type OpenIDRelyingPartyMetadata
- type OpenidFederation
- type OpenidProvider
- type Option
- type RelyingParty
- func (rp *RelyingParty) AddEntityStatementHook(h func(*EntityStatement))
- func (rp *RelyingParty) ClientID() string
- func (rp *RelyingParty) Federation() *OpenidFederation
- func (rp *RelyingParty) NewClient(issuer string) (oidc.Client, error)
- func (rp *RelyingParty) Serve(w http.ResponseWriter, r *http.Request)
- func (rp *RelyingParty) ServeSignedJwks(w http.ResponseWriter, r *http.Request)
- func (rp *RelyingParty) SignEntityStatement() ([]byte, error)
- type RelyingPartyClient
- func (c *RelyingPartyClient) AuthenticationURL(state, nonce, verifier string, options ...oidc.Option) (string, error)
- func (c *RelyingPartyClient) ClientID() string
- func (c *RelyingPartyClient) ExchangeForIdentity(code, verifier string, options ...oidc.Option) (*oidc.TokenResponse, error)
- func (c *RelyingPartyClient) Issuer() string
- func (c *RelyingPartyClient) LogoURI() string
- func (c *RelyingPartyClient) Name() string
- func (c *RelyingPartyClient) RedirectURI() string
- type RelyingPartyConfig
- type RelyingPartyMetadata
- type UserType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddApiKeyTransport ¶
func AddApiKeyTransport(t http.RoundTripper) http.RoundTripper
Types ¶
type CodeChallengeMethod ¶
type CodeChallengeMethod string
const (
CodeChallengeMethodS256 CodeChallengeMethod = "S256"
)
type EntityStatement ¶
type Error ¶
type Error struct {
Operation string `json:"operation"`
ErrorCode string `json:"error"`
Description string `json:"error_description"`
GematikTimestamp int64 `json:"gematik_timestamp,omitempty"`
GematikUUID string `json:"gematik_uuid,omitempty"`
GematikCode string `json:"gematik_code,omitempty"`
// BadDescription captures error_description sent in camelCase ("errorDescription"), which some IDPs
// return in violation of RFC 6749. parseErrorResponse folds it into Description.
BadDescription string `json:"errorDescription,omitempty"`
}
type FederationEntity ¶ added in v0.5.1
type FederationEntity struct {
Name string `yaml:"name,omitempty"`
Contacts []string `yaml:"contacts,omitempty"`
HomepageURI string `yaml:"homepage_uri,omitempty"`
}
FederationEntity holds the variable federation_entity metadata.
type FederationEntityMetadata ¶
type FederationEntityMetadata struct {
Name string `json:"name,omitempty"`
Contacts []string `json:"contacts,omitempty"`
HomepageURI string `json:"homepage_uri,omitempty"`
FederationFetchEndpoint string `json:"federation_fetch_endpoint,omitempty"`
FederationListEndpoint string `json:"federation_list_endpoint,omitempty"`
IdpListEndpoint string `json:"idp_list_endpoint,omitempty"`
}
type IdentityProviderInfo ¶
type Jwk ¶
small trick to make jwk.Key JSON-serializable
func NewJwkFromJson ¶
func (*Jwk) MarshalJSON ¶
func (*Jwk) UnmarshalJSON ¶
type Jwks ¶
small trick to make jwk.Set JSON-serializable
func (*Jwks) MarshalJSON ¶
func (*Jwks) UnmarshalJSON ¶
type KeyConfig ¶ added in v0.5.1
type KeyConfig struct {
KeyPEMPath string `yaml:"key_pem_path,omitempty"`
CertPEMPath string `yaml:"cert_pem_path,omitempty"`
JWKPath string `yaml:"jwk_path,omitempty"`
JWK map[string]any `yaml:"jwk,omitempty"`
Kid string `yaml:"kid,omitempty"`
}
KeyConfig sources one key. Provide exactly one of KeyPEMPath (a PEM private-key file), JWKPath (a JWK file), or JWK (an inline JWK). CertPEMPath is the optional X.509 certificate (PEM) bound to the key — required for the client key (mTLS). The key id is Kid when set, otherwise the RFC 7638 SHA-256 thumbprint; a relying party already registered with a federation master MUST set Kid to the registered key id, or the OP cannot match the signing key (it looks it up by kid in the jwks the master vouches for).
type Metadata ¶
type Metadata struct {
OpenidRelyingParty *OpenIDRelyingPartyMetadata `json:"openid_relying_party,omitempty"`
OpenidProvider *OpenIDProviderMetadata `json:"openid_provider,omitempty"`
FederationEntity *FederationEntityMetadata `json:"federation_entity"`
}
type OpenIDProviderMetadata ¶
type OpenIDProviderMetadata struct {
AuthorizationEndpoint string `json:"authorization_endpoint"`
ClientRegistrationTypesSupported []string `json:"client_registration_types_supported"`
GrantTypesSupported []string `json:"grant_types_supported"`
IDTokenEncryptionAlgValuesSupported []string `json:"id_token_encryption_alg_values_supported"`
IDTokenEncryptionEncValuesSupported []string `json:"id_token_encryption_enc_values_supported"`
IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported"`
Issuer string `json:"issuer"`
LogoURI string `json:"logo_uri"`
OrganizationName string `json:"organization_name"`
PushedAuthorizationRequestEndpoint string `json:"pushed_authorization_request_endpoint"`
RequestAuthenticationMethodsSupported struct {
Ar []string `json:"ar"`
Par []string `json:"par"`
} `json:"request_authentication_methods_supported"`
RequirePushedAuthorizationRequests bool `json:"require_pushed_authorization_requests"`
ResponseModesSupported []string `json:"response_modes_supported"`
ResponseTypesSupported []string `json:"response_types_supported"`
ScopesSupported []string `json:"scopes_supported"`
SignedJwksUri string `json:"signed_jwks_uri"`
SubjectTypesSupported []string `json:"subject_types_supported"`
TokenEndpoint string `json:"token_endpoint"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported"`
UserTypeSupported []UserType `json:"user_type_supported"`
}
type OpenIDRelyingPartyMetadata ¶
type OpenIDRelyingPartyMetadata struct {
SignedJwksUri string `json:"signed_jwks_uri,omitempty"`
Jwks *Jwks `json:"jwks"`
OrganizationName string `json:"organization_name"`
ClientName string `json:"client_name"`
LogoURI string `json:"logo_uri"`
RedirectURIs []string `json:"redirect_uris"`
ResponseTypes []string `json:"response_types"`
ClientRegistrationTypes []string `json:"client_registration_types"`
GrantTypes []string `json:"grant_types"`
RequirePushedAuthorizationRequests bool `json:"require_pushed_authorization_requests"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
DefaultACRValues []string `json:"default_acr_values"`
IDTokenSignedResponseAlg string `json:"id_token_signed_response_alg"`
IDTokenEncryptedResponseAlg string `json:"id_token_encrypted_response_alg"`
IDTokenEncryptedResponseEnc string `json:"id_token_encrypted_response_enc"`
Scope string `json:"scope"`
}
type OpenidFederation ¶
type OpenidFederation struct {
// contains filtered or unexported fields
}
func NewOpenidFederation ¶
func (*OpenidFederation) FederationMasterURL ¶
func (f *OpenidFederation) FederationMasterURL() string
func (*OpenidFederation) FetchEntityStatement ¶
func (f *OpenidFederation) FetchEntityStatement(iss string) (*EntityStatement, error)
fetches and verifies the entity statement for the given issuer
func (*OpenidFederation) FetchIdpList ¶
func (f *OpenidFederation) FetchIdpList() ([]IdentityProviderInfo, error)
func (*OpenidFederation) FetchSignedJwks ¶
func (f *OpenidFederation) FetchSignedJwks(op *EntityStatement) (jwk.Set, error)
type OpenidProvider ¶
type OpenidProvider struct {
Issuer string
}
type Option ¶ added in v0.5.1
type Option func(*federationOptions)
Option configures an OpenidFederation.
func WithHTTPClient ¶ added in v0.5.1
WithHTTPClient supplies the base HTTP client; the federation API key is layered onto a copy of it. When unset, a client with a default timeout is created.
type RelyingParty ¶
type RelyingParty struct {
// contains filtered or unexported fields
}
func NewRelyingPartyFromConfig ¶
func NewRelyingPartyFromConfig(cfg *RelyingPartyConfig) (*RelyingParty, error)
func NewRelyingPartyFromConfigFile ¶
func NewRelyingPartyFromConfigFile(path string) (*RelyingParty, error)
func (*RelyingParty) AddEntityStatementHook ¶ added in v0.5.1
func (rp *RelyingParty) AddEntityStatementHook(h func(*EntityStatement))
AddEntityStatementHook registers a function applied to a copy of the entity statement on every SignEntityStatement call, in registration order. A hook may mutate the copy (e.g. append redirect_uris) and never affects the relying party's base statement. This lets a consumer inject values into the served entity statement without oidf depending on it; add more hooks the same way for future needs.
func (*RelyingParty) ClientID ¶
func (rp *RelyingParty) ClientID() string
func (*RelyingParty) Federation ¶
func (rp *RelyingParty) Federation() *OpenidFederation
func (*RelyingParty) NewClient ¶
func (rp *RelyingParty) NewClient(issuer string) (oidc.Client, error)
func (*RelyingParty) Serve ¶
func (rp *RelyingParty) Serve(w http.ResponseWriter, r *http.Request)
func (*RelyingParty) ServeSignedJwks ¶
func (rp *RelyingParty) ServeSignedJwks(w http.ResponseWriter, r *http.Request)
func (*RelyingParty) SignEntityStatement ¶
func (rp *RelyingParty) SignEntityStatement() ([]byte, error)
type RelyingPartyClient ¶
type RelyingPartyClient struct {
// contains filtered or unexported fields
}
func (*RelyingPartyClient) AuthenticationURL ¶
func (*RelyingPartyClient) ClientID ¶
func (c *RelyingPartyClient) ClientID() string
func (*RelyingPartyClient) ExchangeForIdentity ¶
func (c *RelyingPartyClient) ExchangeForIdentity(code, verifier string, options ...oidc.Option) (*oidc.TokenResponse, error)
func (*RelyingPartyClient) Issuer ¶
func (c *RelyingPartyClient) Issuer() string
func (*RelyingPartyClient) LogoURI ¶
func (c *RelyingPartyClient) LogoURI() string
func (*RelyingPartyClient) Name ¶
func (c *RelyingPartyClient) Name() string
func (*RelyingPartyClient) RedirectURI ¶
func (c *RelyingPartyClient) RedirectURI() string
type RelyingPartyConfig ¶
type RelyingPartyConfig struct {
BaseDir string `yaml:"-"`
// Subject is this relying party's entity identifier — its own public URL — and also the entity
// statement's iss/sub and the OIDF client_id.
Subject string `yaml:"sub" validate:"required"`
// FedMasterURL is the federation master. Its trust-anchor signing key is resolved from a built-in table
// of known gematik masters (see knownFedMasters); set FedMasterJWK to override or for an unlisted master.
FedMasterURL string `yaml:"fed_master_url" validate:"required"`
FedMasterJWK *Jwk `yaml:"fed_master_jwk,omitempty"`
// SignKey signs the entity statement; EncKey decrypts the JWE id_token; ClientKey authenticates the
// self_signed_tls_client_auth mTLS calls (its cert_pem_path is required). Each is a KeyConfig.
SignKey KeyConfig `yaml:"sign_key" validate:"required"`
EncKey KeyConfig `yaml:"enc_key" validate:"required"`
ClientKey KeyConfig `yaml:"client_key" validate:"required"`
// RelyingParty + FederationEntity are the deployment-specific entity-statement metadata; the rest is
// defaulted.
RelyingParty RelyingPartyMetadata `yaml:"relying_party" validate:"required"`
FederationEntity FederationEntity `yaml:"federation_entity"`
// Scopes requested from the OpenID provider's authorization endpoint (which identity claims it returns).
// When empty, defaultOPScopes is used.
Scopes []string `yaml:"scopes,omitempty"`
// HTTPClient is the base client for federation and relying-party calls. Not serialized; supplied
// programmatically. When nil, a client with a default timeout is created. The relying party's
// authenticated calls layer mutual TLS onto a copy of it.
HTTPClient *http.Client `yaml:"-"`
}
RelyingPartyConfig configures a gematik OpenID Federation relying party. Only deployment-specific values are required; the invariant gematik OIDF metadata (response_types, grant_types, client_registration_types, token_endpoint_auth_method, id_token algorithms, PAR) is filled in by buildMetadata.
func LoadRelyingPartyConfig ¶
func LoadRelyingPartyConfig(path string) (*RelyingPartyConfig, error)
type RelyingPartyMetadata ¶ added in v0.5.1
type RelyingPartyMetadata struct {
ClientName string `yaml:"client_name" validate:"required"`
RedirectURIs []string `yaml:"redirect_uris" validate:"required,min=1"`
OrganizationName string `yaml:"organization_name,omitempty"`
LogoURI string `yaml:"logo_uri,omitempty"`
Scope string `yaml:"scope,omitempty"` // default defaultMetadataScope
DefaultACRValues []string `yaml:"default_acr_values,omitempty"` // default [defaultACRValue]
SignedJwksURI string `yaml:"signed_jwks_uri,omitempty"`
}
RelyingPartyMetadata holds the variable openid_relying_party fields; the OIDF boilerplate is defaulted.