frontend config polish (#404)

This commit is contained in:
Michael Quigley 2023-09-25 14:15:19 -04:00
parent ed96a465a0
commit 22807406d6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 17 additions and 13 deletions

View File

@ -18,9 +18,13 @@ func (a *privateResourceAllocator) allocate(envZId, shrToken string, params shar
for _, authUser := range params.Body.AuthUsers {
authUsers = append(authUsers, &sdk.AuthUserConfig{Username: authUser.Username, Password: authUser.Password})
}
authScheme, err := sdk.ParseAuthScheme(params.Body.AuthScheme)
if err != nil {
return "", nil, err
}
options := &zrokEdgeSdk.FrontendOptions{
AuthScheme: params.Body.AuthScheme,
AuthUsers: authUsers,
AuthScheme: authScheme,
BasicAuthUsers: authUsers,
Oauth: &sdk.OauthConfig{
Provider: params.Body.OauthProvider,
EmailDomains: params.Body.OauthEmailDomains,

View File

@ -18,9 +18,13 @@ func (a *publicResourceAllocator) allocate(envZId, shrToken string, frontendZIds
for _, authUser := range params.Body.AuthUsers {
authUsers = append(authUsers, &sdk.AuthUserConfig{Username: authUser.Username, Password: authUser.Password})
}
authScheme, err := sdk.ParseAuthScheme(params.Body.AuthScheme)
if err != nil {
return "", nil, err
}
options := &zrokEdgeSdk.FrontendOptions{
AuthScheme: params.Body.AuthScheme,
AuthUsers: authUsers,
AuthScheme: authScheme,
BasicAuthUsers: authUsers,
Oauth: &sdk.OauthConfig{
Provider: params.Body.OauthProvider,
EmailDomains: params.Body.OauthEmailDomains,

View File

@ -12,22 +12,18 @@ import (
)
type FrontendOptions struct {
AuthScheme string
AuthUsers []*sdk.AuthUserConfig
Oauth *sdk.OauthConfig
AuthScheme sdk.AuthScheme
BasicAuthUsers []*sdk.AuthUserConfig
Oauth *sdk.OauthConfig
}
func CreateConfig(cfgTypeZId, envZId, shrToken string, options *FrontendOptions, edge *rest_management_api_client.ZitiEdgeManagement) (cfgZId string, err error) {
authScheme, err := sdk.ParseAuthScheme(options.AuthScheme)
if err != nil {
return "", err
}
cfg := &sdk.FrontendConfig{
AuthScheme: authScheme,
AuthScheme: options.AuthScheme,
}
if cfg.AuthScheme == sdk.Basic {
cfg.BasicAuth = &sdk.BasicAuthConfig{}
for _, authUser := range options.AuthUsers {
for _, authUser := range options.BasicAuthUsers {
cfg.BasicAuth.Users = append(cfg.BasicAuth.Users, &sdk.AuthUserConfig{Username: authUser.Username, Password: authUser.Password})
}
}