Skip to content

Commit ecdef19

Browse files
authored
[FSSDK-10734] update regex to support base64 char for SDK Key & access token (#427)
* add support for base64 char for SDK Key & access token * fix test * fix test * update regex
1 parent e80529d commit ecdef19

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Diff for: config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ client:
177177
## Validation Regex on the request SDK Key
178178
## By default Agent assumes only alphanumeric characters as part of the SDK Key string.
179179
## https://github.com/google/re2/wiki/Syntax
180-
sdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$"
180+
sdkKeyRegex: "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$"
181181
## configure optional User profile service
182182
userProfileService:
183183
default: ""

Diff for: config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewDefaultConfig() *AgentConfig {
8282
DatafileURLTemplate: "https://cdn.optimizely.com/datafiles/%s.json",
8383
EventURL: "https://logx.optimizely.com/v1/events",
8484
// https://github.com/google/re2/wiki/Syntax
85-
SdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$",
85+
SdkKeyRegex: "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$",
8686
UserProfileService: UserProfileServiceConfigs{
8787
"default": "",
8888
"services": map[string]interface{}{},

Diff for: config/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestDefaultConfig(t *testing.T) {
8282
assert.Equal(t, 30*time.Second, conf.Client.FlushInterval)
8383
assert.Equal(t, "https://cdn.optimizely.com/datafiles/%s.json", conf.Client.DatafileURLTemplate)
8484
assert.Equal(t, "https://logx.optimizely.com/v1/events", conf.Client.EventURL)
85-
assert.Equal(t, "^[\\w=]+(:[\\w=]+)?$", conf.Client.SdkKeyRegex)
85+
assert.Equal(t, "^[a-zA-Z0-9+/=_]+(:[a-zA-Z0-9+/=_]+)?$", conf.Client.SdkKeyRegex)
8686
assert.Equal(t, "", conf.Client.UserProfileService["default"])
8787
assert.Equal(t, false, conf.Client.ODP.Disable)
8888
assert.Equal(t, 1*time.Second, conf.Client.ODP.EventsFlushInterval)

Diff for: pkg/optimizely/cache_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,11 @@ func (s *DefaultLoaderTestSuite) TestDefaultRegexValidator() {
781781
{"abc:def:hij", false},
782782
{"abc:", false},
783783
{"123sdkKey:accesTokenWith=", true},
784+
{"abc+123", true},
785+
{"abc-123", false},
786+
{"abc/123", true},
787+
{"abc:def=", true},
788+
{"abc:acd+def/=", true},
784789
}
785790

786791
conf := config.NewDefaultConfig()

0 commit comments

Comments
 (0)