You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
666 B

package identity
import (
"fmt"
"maze.io/gate/pkg/core"
)
// DefaultProvider is our default identity provider.
var DefaultProvider = &systemIdentityProvider{}
type Config struct {
System *systemIdentityProvider
}
func (config *Config) Provider() (core.IdentityProvider, error) {
if config == nil {
// Fast path.
return DefaultProvider, nil
}
var providers []core.IdentityProvider
if config.System != nil {
providers = append(providers, config.System)
}
switch len(providers) {
case 0:
return DefaultProvider, nil
case 1:
return providers[0], nil
default:
return nil, fmt.Errorf("identity: %d providers configured", len(providers))
}
}