Skip to content

Commit

Permalink
AUTH_COOKIE_DOMAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Aug 15, 2024
1 parent 363edd8 commit efdcdf2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions backend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ AUTH_ST_TTL=300
AUTH_SESSION_TTL=86400
AUTH_SERVICES_LOGOUT=http://localhost:5203/api/v1/auth/sso-signout
AUTH_IS_HTTPS=false
AUTH_COOKIE_DOMAIN=localhost

CORS_ALLOW_ORIGINS=http://localhost:3000
18 changes: 10 additions & 8 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ type OauthConfig struct {
}

type AuthConfig struct {
STTTL int
SessionTTL int
Services []string
IsHTTPS bool
STTTL int
SessionTTL int
Services []string
IsHTTPS bool
CookieDomain string
}

type CorsConfig struct {
Expand Down Expand Up @@ -82,10 +83,11 @@ func LoadConfig() (*Config, error) {
servicesLogoutString := os.Getenv("AUTH_SERVICES_LOGOUT")
servicesLogout := strings.Split(servicesLogoutString, ",")
authConfig := AuthConfig{
STTTL: int(STTTL),
SessionTTL: int(sessionTTL),
Services: servicesLogout,
IsHTTPS: os.Getenv("AUTH_IS_HTTPS") == "true",
STTTL: int(STTTL),
SessionTTL: int(sessionTTL),
Services: servicesLogout,
IsHTTPS: os.Getenv("AUTH_IS_HTTPS") == "true",
CookieDomain: os.Getenv("AUTH_COOKIE_DOMAIN"),
}

return &Config{
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/auth/auth.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (h *handlerImpl) VerifyGoogleLogin(c context.Ctx) {
return
}

c.SetCookie("CASTGC", session.Token, h.conf.SessionTTL, "/", "localhost", h.conf.IsHTTPS, true)
c.SetCookie("CASTGC", session.Token, h.conf.SessionTTL, "/", h.conf.CookieDomain, h.conf.IsHTTPS, true)

c.JSON(200, &dto.ServiceTicketToken{
ServiceTicket: serviceTicket.Token,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.qa.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
AUTH_SESSION_TTL: 86400
AUTH_SERVICES_LOGOUT: http://sso_svc_1:80/api/v1/auth/sso-signout,http://sso_svc_2:80/api/v1/auth/sso-signout
AUTH_IS_HTTPS: "false"
AUTH_COOKIE_DOMAIN: localhost
CORS_ALLOW_ORIGINS: http://localhost:3000,http://sso_svc_1:5203,http://sso_svc_2:5204
networks:
- sso
Expand Down

0 comments on commit efdcdf2

Please sign in to comment.