|
|
|
@ -3,16 +3,12 @@ package wire
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"sync"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Options holds the Wire ACME extension options
|
|
|
|
|
type Options struct {
|
|
|
|
|
OIDC *OIDCOptions `json:"oidc,omitempty"`
|
|
|
|
|
DPOP *DPOPOptions `json:"dpop,omitempty"`
|
|
|
|
|
|
|
|
|
|
validateOnce sync.Once
|
|
|
|
|
validationErr error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetOIDCOptions returns the OIDC options.
|
|
|
|
@ -31,17 +27,10 @@ func (o *Options) GetDPOPOptions() *DPOPOptions {
|
|
|
|
|
return o.DPOP
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate validates and initializes the Wire OIDC and DPoP options.
|
|
|
|
|
//
|
|
|
|
|
// TODO(hs): find a good way to perform this only once.
|
|
|
|
|
func (o *Options) Validate() error {
|
|
|
|
|
o.validateOnce.Do(
|
|
|
|
|
func() {
|
|
|
|
|
o.validationErr = validate(o)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return o.validationErr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func validate(o *Options) error {
|
|
|
|
|
if oidc := o.GetOIDCOptions(); oidc != nil {
|
|
|
|
|
if err := oidc.validateAndInitialize(); err != nil {
|
|
|
|
|
return fmt.Errorf("failed initializing OIDC options: %w", err)
|
|
|
|
|