wire skip interstitial into public share config (#704)

This commit is contained in:
Michael Quigley 2024-07-24 11:28:20 -04:00
parent 275666c2b2
commit d593232cf6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 11 additions and 3 deletions

View File

@ -133,7 +133,12 @@ func (h *shareHandler) Handle(params share.ShareParams, principal *rest_model_zr
logrus.Infof("added frontend selection '%v' with ziti identity '%v' for share '%v'", frontendSelection, sfe.ZId, shrToken) logrus.Infof("added frontend selection '%v' with ziti identity '%v' for share '%v'", frontendSelection, sfe.ZId, shrToken)
} }
} }
shrZId, frontendEndpoints, err = newPublicResourceAllocator().allocate(envZId, shrToken, frontendZIds, frontendTemplates, params, edge) skipInterstitial, err := str.IsAccountGrantedSkipInterstitial(int(principal.ID), trx)
if err != nil {
logrus.Errorf("error checking skip interstitial for account '%v': %v", principal.Email, err)
return share.NewShareInternalServerError()
}
shrZId, frontendEndpoints, err = newPublicResourceAllocator().allocate(envZId, shrToken, frontendZIds, frontendTemplates, params, !skipInterstitial, edge)
if err != nil { if err != nil {
logrus.Error(err) logrus.Error(err)
return share.NewShareInternalServerError() return share.NewShareInternalServerError()

View File

@ -13,7 +13,7 @@ func newPublicResourceAllocator() *publicResourceAllocator {
return &publicResourceAllocator{} return &publicResourceAllocator{}
} }
func (a *publicResourceAllocator) allocate(envZId, shrToken string, frontendZIds, frontendTemplates []string, params share.ShareParams, edge *rest_management_api_client.ZitiEdgeManagement) (shrZId string, frontendEndpoints []string, err error) { func (a *publicResourceAllocator) allocate(envZId, shrToken string, frontendZIds, frontendTemplates []string, params share.ShareParams, interstitial bool, edge *rest_management_api_client.ZitiEdgeManagement) (shrZId string, frontendEndpoints []string, err error) {
var authUsers []*sdk.AuthUserConfig var authUsers []*sdk.AuthUserConfig
for _, authUser := range params.Body.AuthUsers { for _, authUser := range params.Body.AuthUsers {
authUsers = append(authUsers, &sdk.AuthUserConfig{Username: authUser.Username, Password: authUser.Password}) authUsers = append(authUsers, &sdk.AuthUserConfig{Username: authUser.Username, Password: authUser.Password})
@ -23,6 +23,7 @@ func (a *publicResourceAllocator) allocate(envZId, shrToken string, frontendZIds
return "", nil, err return "", nil, err
} }
options := &zrokEdgeSdk.FrontendOptions{ options := &zrokEdgeSdk.FrontendOptions{
Interstitial: interstitial,
AuthScheme: authScheme, AuthScheme: authScheme,
BasicAuthUsers: authUsers, BasicAuthUsers: authUsers,
Oauth: &sdk.OauthConfig{ Oauth: &sdk.OauthConfig{

View File

@ -12,6 +12,7 @@ import (
) )
type FrontendOptions struct { type FrontendOptions struct {
Interstitial bool
AuthScheme sdk.AuthScheme AuthScheme sdk.AuthScheme
BasicAuthUsers []*sdk.AuthUserConfig BasicAuthUsers []*sdk.AuthUserConfig
Oauth *sdk.OauthConfig Oauth *sdk.OauthConfig
@ -19,6 +20,7 @@ type FrontendOptions struct {
func CreateConfig(cfgTypeZId, envZId, shrToken string, options *FrontendOptions, edge *rest_management_api_client.ZitiEdgeManagement) (cfgZId string, err error) { func CreateConfig(cfgTypeZId, envZId, shrToken string, options *FrontendOptions, edge *rest_management_api_client.ZitiEdgeManagement) (cfgZId string, err error) {
cfg := &sdk.FrontendConfig{ cfg := &sdk.FrontendConfig{
Interstitial: options.Interstitial,
AuthScheme: options.AuthScheme, AuthScheme: options.AuthScheme,
} }
if cfg.AuthScheme == sdk.Basic { if cfg.AuthScheme == sdk.Basic {