Skip to content

Commit

Permalink
[installer] Change cookie name (#18958)
Browse files Browse the repository at this point in the history
* [installer] Change cookie name

* fix test

* fix
  • Loading branch information
easyCZ authored Oct 19, 2023
1 parent 7f3b3c7 commit f09c35a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion install/installer/pkg/components/auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ func GetConfig(ctx *common.RenderContext) ([]corev1.Volume, []corev1.VolumeMount
func cookieNameFromDomain(domain string) string {
// replace all non-word characters with underscores
derived := regexp.MustCompile(`[\W_]+`).ReplaceAllString(domain, "_")
return "_" + derived + "_jwt_"
return "_" + derived + "_jwt2_"
}
16 changes: 8 additions & 8 deletions install/installer/pkg/components/auth/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ func TestCookieNameFromDomain(t *testing.T) {
{
name: "Simple Domain",
domain: "example.com",
expectedOutcome: "_example_com_jwt_",
expectedOutcome: "_example_com_jwt2_",
},
{
name: "Domain with Underscore",
domain: "example_test.com",
expectedOutcome: "_example_test_com_jwt_",
expectedOutcome: "_example_test_com_jwt2_",
},
{
name: "Domain with Hyphen",
domain: "example-test.com",
expectedOutcome: "_example_test_com_jwt_",
expectedOutcome: "_example_test_com_jwt2_",
},
{
name: "Domain with Special Characters",
domain: "example&test.com",
expectedOutcome: "_example_test_com_jwt_",
expectedOutcome: "_example_test_com_jwt2_",
},
{
name: "Subdomain",
domain: "subdomain.example.com",
expectedOutcome: "_subdomain_example_com_jwt_",
expectedOutcome: "_subdomain_example_com_jwt2_",
},
{
name: "Subdomain with Hyphen",
domain: "sub-domain.example.com",
expectedOutcome: "_sub_domain_example_com_jwt_",
expectedOutcome: "_sub_domain_example_com_jwt2_",
},
{
name: "Subdomain with Underscore",
domain: "sub_domain.example.com",
expectedOutcome: "_sub_domain_example_com_jwt_",
expectedOutcome: "_sub_domain_example_com_jwt2_",
},
{
name: "Subdomain with Special Characters",
domain: "sub&domain.example.com",
expectedOutcome: "_sub_domain_example_com_jwt_",
expectedOutcome: "_sub_domain_example_com_jwt2_",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestConfigMap(t *testing.T) {
LifetimeSeconds: int64((24 * 7 * time.Hour).Seconds()),
Issuer: "https://test.domain.everything.awesome.is",
Cookie: config.CookieConfig{
Name: "_test_domain_everything_awesome_is_jwt_",
Name: "_test_domain_everything_awesome_is_jwt2_",
MaxAge: int64((24 * 7 * time.Hour).Seconds()),
SameSite: "lax",
Secure: true,
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/server/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestConfigMap(t *testing.T) {
LifetimeSeconds: int64((7 * 24 * time.Hour).Seconds()),
Issuer: "https://awesome.domain",
Cookie: auth.CookieConfig{
Name: "_awesome_domain_jwt_",
Name: "_awesome_domain_jwt2_",
MaxAge: int64((7 * 24 * time.Hour).Seconds()),
SameSite: "lax",
Secure: true,
Expand Down

0 comments on commit f09c35a

Please sign in to comment.