Ejemplo n.º 1
0
func (c *Config) ApplyDelegatingAuthenticationOptions(o *options.DelegatingAuthenticationOptions) (*Config, error) {
	if o == nil {
		return c, nil
	}

	var err error
	c, err = c.applyClientCert(o.ClientCert.ClientCA)
	if err != nil {
		return nil, fmt.Errorf("unable to load client CA file: %v", err)
	}
	c, err = c.applyClientCert(o.RequestHeader.ClientCAFile)
	if err != nil {
		return nil, fmt.Errorf("unable to load client CA file: %v", err)
	}

	cfg, err := o.ToAuthenticationConfig()
	if err != nil {
		return nil, err
	}
	authenticator, securityDefinitions, err := cfg.New()
	if err != nil {
		return nil, err
	}

	c.Authenticator = authenticator
	c.OpenAPIConfig.SecurityDefinitions = securityDefinitions
	c.SupportsBasicAuth = false

	return c, nil
}
Ejemplo n.º 2
0
func (c *Config) ApplyDelegatingAuthenticationOptions(o *options.DelegatingAuthenticationOptions) (*Config, error) {
	if o == nil {
		return c, nil
	}

	cfg, err := o.ToAuthenticationConfig()
	if err != nil {
		return nil, err
	}
	authenticator, securityDefinitions, err := cfg.New()
	if err != nil {
		return nil, err
	}

	c.Authenticator = authenticator
	c.OpenAPIConfig.SecurityDefinitions = securityDefinitions
	c.SupportsBasicAuth = false

	return c, nil
}