Skip to content

Commit 396b1ab

Browse files
committed
moved config param sso.configurator_root_path to ui.base_url
added default values for ui.base_url updated sso doc
1 parent 1ddd8ba commit 396b1ab

File tree

6 files changed

+10
-24
lines changed

6 files changed

+10
-24
lines changed

configurator/backend/appconfig/appconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func setDefaultParams(containerized bool) {
2323
viper.SetDefault("server.self_hosted", true)
2424
viper.SetDefault("server.log.level", "info")
2525
viper.SetDefault("server.allowed_domains", []string{"localhost", jcors.AppTopLevelDomainTemplate})
26+
viper.SetDefault("ui.base_url", "/")
2627

2728
if containerized {
2829
viper.SetDefault("server.log.path", "/home/configurator/data/logs")

configurator/backend/authorization/boxyhq.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const (
1919
type SSOProvider interface {
2020
GetUser(code string) (*UserEntity, error)
2121
AuthLink() string
22-
GetConfiguration() *SSOConfig
2322
AccessTokenTTL() time.Duration
2423
Name() string
2524
}
@@ -106,10 +105,6 @@ func (bp *BoxyHQProvider) AuthLink() string {
106105
return authLink
107106
}
108107

109-
func (bp *BoxyHQProvider) GetConfiguration() *SSOConfig {
110-
return bp.ssoConfig
111-
}
112-
113108
func (bp *BoxyHQProvider) Name() string {
114109
return BoxyHQ
115110
}

configurator/backend/authorization/service.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type SSOConfig struct {
4646
Product string `json:"product" validate:"required"`
4747
Host string `json:"host" validate:"required"`
4848
AccessTokenTTLSeconds time.Duration `json:"access_token_ttl_seconds" validate:"required"`
49-
ConfiguratorRootPath string `json:"configurator_root_path"`
5049
}
5150

5251
type Service struct {
@@ -99,7 +98,7 @@ func CreateSSOProvider(vp *viper.Viper) SSOProvider {
9998
var err error
10099

101100
ssoConfig := &SSOConfig{}
102-
envConfig := os.Getenv("SSO_CONFIG")
101+
envConfig := os.Getenv("JITSU_SSO_CONFIG")
103102

104103
if envConfig == "" {
105104
vpSSO := vp.Sub("sso")
@@ -114,12 +113,11 @@ func CreateSSOProvider(vp *viper.Viper) SSOProvider {
114113
Product: vpSSO.GetString("product"),
115114
Host: vpSSO.GetString("host"),
116115
AccessTokenTTLSeconds: vpSSO.GetDuration("access_token_ttl_seconds"),
117-
ConfiguratorRootPath: vpSSO.GetString("configurator_root_path"),
118116
}
119117
} else {
120118
err = json.Unmarshal([]byte(envConfig), ssoConfig)
121119
if err != nil {
122-
logging.Errorf("Can't unmarshal SSO_CONFIG from env variables: %v", err)
120+
logging.Errorf("Can't unmarshal JITSU_SSO_CONFIG from env variables: %v", err)
123121
return nil
124122
}
125123
}
@@ -421,13 +419,6 @@ func (s *Service) GetSSOAuthorizationLink() string {
421419
return s.ssoAuthProvider.AuthLink()
422420
}
423421

424-
func (s *Service) GetConfiguratorRootPath() string {
425-
if s.ssoAuthProvider == nil {
426-
return ""
427-
}
428-
return s.ssoAuthProvider.GetConfiguration().ConfiguratorRootPath
429-
}
430-
431422
func (s *Service) Close() error {
432423
if err := s.authProvider.Close(); err != nil {
433424
return fmt.Errorf("Error closing authorization provider: %v", err)

configurator/backend/handlers/sso_auth.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/gin-gonic/gin"
66
"github.com/jitsucom/jitsu/configurator/authorization"
7+
"github.com/spf13/viper"
78
"net/http"
89
)
910

@@ -39,18 +40,15 @@ func (oh *SSOAuthHandler) Handler(c *gin.Context) {
3940
return
4041
}
4142

42-
crp := oh.authService.GetConfiguratorRootPath()
43-
if crp == "" {
44-
crp = "/"
45-
}
43+
uiBaseUrl := viper.GetString("UI_BASE_URL")
4644

4745
td, err := oh.authService.SSOAuthenticate(code)
4846
if err != nil {
49-
c.String(http.StatusOK, errorTmpl, err, crp)
47+
c.String(http.StatusOK, errorTmpl, err, uiBaseUrl)
5048
return
5149
}
5250

53-
c.String(http.StatusOK, successTmpl, td.AccessTokenEntity.AccessToken, td.RefreshTokenEntity.RefreshToken, crp)
51+
c.String(http.StatusOK, successTmpl, td.AccessTokenEntity.AccessToken, td.RefreshTokenEntity.RefreshToken, uiBaseUrl)
5452

5553
return
5654
}

docker/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ trap graceful_exit SIGQUIT SIGTERM SIGINT SIGHUP
6767
# ENV variables
6868
export JITSU_CONFIGURATOR_URL=http://localhost:7000
6969
export JITSU_SERVER_URL=http://localhost:8001
70+
export UI_BASE_URL=/configurator
7071
## Backward compatibility (Joint image has enabled user recognition by default)
7172
export USER_RECOGNITION_ENABLED=${USER_RECOGNITION_ENABLED:=true}
7273

documentation/configurator-configuration/sso-authentication/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ sso:
2424
configurator_root_path: '/configurator'
2525
```
2626
27-
or you can configure it with env variable SSO_CONFIG:
27+
or you can configure it with env variable `JITSU_SSO_CONFIG`:
2828

2929
```
30-
export SSO_CONFIG='{"provider": "boxyhq", "host": "https://boxyhq.com", "tenant": "boxyhq.com", "product": "jitsu", "access_token_ttl_seconds": 86400, "configurator_root_path": "/configurator"}'
30+
export JITSU_SSO_CONFIG='{"provider": "boxyhq", "host": "https://boxyhq.com", "tenant": "boxyhq.com", "product": "jitsu", "access_token_ttl_seconds": 86400, "configurator_root_path": "/configurator"}'
3131
```
3232
3333
After you have configured the SSO auth, the "Continue with SSO" button will appear on the authorization page.

0 commit comments

Comments
 (0)