Skip to content

Commit

Permalink
[FSSDK-10734] update regex to support base64 char for SDK Key & acces…
Browse files Browse the repository at this point in the history
…s token (#427)

* add support for base64 char for SDK Key & access token

* fix test

* fix test

* update regex
  • Loading branch information
pulak-opti authored Oct 8, 2024
1 parent e80529d commit ecdef19
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ client:
## Validation Regex on the request SDK Key
## By default Agent assumes only alphanumeric characters as part of the SDK Key string.
## https://github.com/google/re2/wiki/Syntax
sdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$"
sdkKeyRegex: "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$"
## configure optional User profile service
userProfileService:
default: ""
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDefaultConfig() *AgentConfig {
DatafileURLTemplate: "https://cdn.optimizely.com/datafiles/%s.json",
EventURL: "https://logx.optimizely.com/v1/events",
// https://github.com/google/re2/wiki/Syntax
SdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$",
SdkKeyRegex: "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$",
UserProfileService: UserProfileServiceConfigs{
"default": "",
"services": map[string]interface{}{},
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestDefaultConfig(t *testing.T) {
assert.Equal(t, 30*time.Second, conf.Client.FlushInterval)
assert.Equal(t, "https://cdn.optimizely.com/datafiles/%s.json", conf.Client.DatafileURLTemplate)
assert.Equal(t, "https://logx.optimizely.com/v1/events", conf.Client.EventURL)
assert.Equal(t, "^[\\w=]+(:[\\w=]+)?$", conf.Client.SdkKeyRegex)
assert.Equal(t, "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$", conf.Client.SdkKeyRegex)
assert.Equal(t, "", conf.Client.UserProfileService["default"])
assert.Equal(t, false, conf.Client.ODP.Disable)
assert.Equal(t, 1*time.Second, conf.Client.ODP.EventsFlushInterval)
Expand Down
5 changes: 5 additions & 0 deletions pkg/optimizely/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ func (s *DefaultLoaderTestSuite) TestDefaultRegexValidator() {
{"abc:def:hij", false},
{"abc:", false},
{"123sdkKey:accesTokenWith=", true},
{"abc+123", true},
{"abc-123", false},
{"abc/123", true},
{"abc:def=", true},
{"abc:acd+def/=", true},
}

conf := config.NewDefaultConfig()
Expand Down

0 comments on commit ecdef19

Please sign in to comment.