2023-07-17 22:45:20 +02:00
|
|
|
package sdk
|
2022-08-15 23:29:31 +02:00
|
|
|
|
2022-08-16 17:55:26 +02:00
|
|
|
import "github.com/pkg/errors"
|
|
|
|
|
2022-08-15 23:29:31 +02:00
|
|
|
const ZrokProxyConfig = "zrok.proxy.v1"
|
|
|
|
|
|
|
|
type ProxyConfig struct {
|
|
|
|
AuthScheme AuthScheme `json:"auth_scheme"`
|
2022-08-16 17:55:26 +02:00
|
|
|
BasicAuth *BasicAuth `json:"basic_auth"`
|
2023-02-22 16:37:07 +01:00
|
|
|
OauthAuth *OauthAuth `json:"oauth"`
|
2022-08-15 23:29:31 +02:00
|
|
|
}
|
2022-08-16 17:27:31 +02:00
|
|
|
|
|
|
|
type BasicAuth struct {
|
2022-08-16 17:43:17 +02:00
|
|
|
Users []*AuthUser `json:"users"`
|
2022-08-16 17:27:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type AuthUser 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
|
|
|
}
|
2022-08-16 17:55:26 +02:00
|
|
|
|
2023-02-22 16:37:07 +01:00
|
|
|
type OauthAuth struct {
|
|
|
|
Provider string `json:"provider"`
|
|
|
|
EmailDomains []string `json:"email_domains"`
|
|
|
|
}
|
|
|
|
|
2022-08-16 17:55:26 +02:00
|
|
|
func ParseAuthScheme(authScheme string) (AuthScheme, error) {
|
|
|
|
switch authScheme {
|
|
|
|
case string(None):
|
|
|
|
return None, nil
|
|
|
|
case string(Basic):
|
|
|
|
return Basic, nil
|
2023-02-22 16:37:07 +01:00
|
|
|
case string(Oauth):
|
|
|
|
return Oauth, nil
|
2022-08-16 17:55:26 +02:00
|
|
|
default:
|
|
|
|
return None, errors.Errorf("unknown auth scheme '%v'", authScheme)
|
|
|
|
}
|
|
|
|
}
|