You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
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.
|
|
func (o *Options) GetOIDCOptions() *OIDCOptions {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
return o.OIDC
|
|
}
|
|
|
|
// GetDPOPOptions returns the DPoP options.
|
|
func (o *Options) GetDPOPOptions() *DPOPOptions {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
return o.DPOP
|
|
}
|
|
|
|
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)
|
|
}
|
|
} else {
|
|
return errors.New("no OIDC options available")
|
|
}
|
|
|
|
if dpop := o.GetDPOPOptions(); dpop != nil {
|
|
if err := dpop.validateAndInitialize(); err != nil {
|
|
return fmt.Errorf("failed initializing DPoP options: %w", err)
|
|
}
|
|
} else {
|
|
return errors.New("no DPoP options available")
|
|
}
|
|
|
|
return nil
|
|
}
|