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.
36 lines
692 B
36 lines
692 B
package sharedmodel
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"whiteboxsystems.nl/openkvpoc/openkv"
|
|
)
|
|
|
|
type AuthConfig struct {
|
|
gorm.Model
|
|
Raw string
|
|
Method openkv.AuthMethod
|
|
}
|
|
|
|
func (cfg AuthConfig) Clone() *AuthConfig {
|
|
return &AuthConfig{
|
|
Raw: cfg.Raw,
|
|
Method: cfg.Method,
|
|
}
|
|
}
|
|
|
|
func NewAuthConfig(cfg *openkv.AuthConfig) *AuthConfig {
|
|
authConfig := &AuthConfig{
|
|
Method: cfg.Method,
|
|
}
|
|
|
|
switch cfg.Method {
|
|
case openkv.AuthMethod_JWT:
|
|
authConfig.Raw = cfg.GetJwtConfig().GetPublicKey()
|
|
case openkv.AuthMethod_APIToken:
|
|
authConfig.Raw = cfg.GetApiTokenConfig().GetToken()
|
|
case openkv.AuthMethod_mTLS:
|
|
authConfig.Raw = cfg.GetMtlsConfig().GetPublicKey()
|
|
}
|
|
|
|
return authConfig
|
|
}
|
|
|