zrok/sdk/config.go

40 lines
943 B
Go
Raw Normal View History

package sdk
2022-08-15 23:29:31 +02:00
import "github.com/pkg/errors"
2022-08-15 23:29:31 +02:00
const ZrokProxyConfig = "zrok.proxy.v1"
type FrontendConfig struct {
AuthScheme AuthScheme `json:"auth_scheme"`
BasicAuth *BasicAuthConfig `json:"basic_auth"`
2023-09-25 20:06:14 +02:00
OauthAuth *OauthConfig `json:"oauth"`
2022-08-15 23:29:31 +02:00
}
2022-08-16 17:27:31 +02:00
type BasicAuthConfig struct {
Users []*AuthUserConfig `json:"users"`
2022-08-16 17:27:31 +02:00
}
type AuthUserConfig struct {
2022-08-16 17:43:17 +02:00
Username string `json:"username"`
Password string `json:"password"`
2022-08-16 17:27:31 +02:00
}
2023-09-25 20:06:14 +02:00
type OauthConfig struct {
2023-09-05 18:50:41 +02:00
Provider string `json:"provider"`
EmailDomains []string `json:"email_domains"`
AuthorizationCheckInterval string `json:"authorization_check_interval"`
}
func ParseAuthScheme(authScheme string) (AuthScheme, error) {
switch authScheme {
case string(None):
return None, nil
case string(Basic):
return Basic, nil
case string(Oauth):
return Oauth, nil
default:
return None, errors.Errorf("unknown auth scheme '%v'", authScheme)
}
}