Skip to content

Commit e80529d

Browse files
authored
[FSSDK-10734] update regex to allow = character (#426)
* add doc in config.yaml for secure env datafileURL template * update regex to allow special characters * update unit test * update regex * update config unit test
1 parent 071d437 commit e80529d

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ client:
170170
## the maximum time between events being dispatched
171171
flushInterval: 30s
172172
## Template URL for SDK datafile location. The template should specify a "%s" token for SDK key substitution.
173+
## For secure environments, the datafileURLTemplate should be set to "https://config.optimizely.com/datafiles/auth/%s.json"
173174
datafileURLTemplate: "https://cdn.optimizely.com/datafiles/%s.json"
174175
## URL for dispatching events.
175176
eventURL: "https://logx.optimizely.com/v1/events"
176177
## Validation Regex on the request SDK Key
177178
## By default Agent assumes only alphanumeric characters as part of the SDK Key string.
178179
## https://github.com/google/re2/wiki/Syntax
179-
sdkKeyRegex: "^\\w+(:\\w+)?$"
180+
sdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$"
180181
## configure optional User profile service
181182
userProfileService:
182183
default: ""

config/config.go

Lines changed: 1 addition & 1 deletion
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: "^[\\w=]+(:[\\w=]+)?$",
8686
UserProfileService: UserProfileServiceConfigs{
8787
"default": "",
8888
"services": map[string]interface{}{},

config/config_test.go

Lines changed: 1 addition & 1 deletion
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, "^[\\w=]+(:[\\w=]+)?$", 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)

pkg/optimizely/cache_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ func (s *DefaultLoaderTestSuite) TestDefaultRegexValidator() {
780780
{":", false},
781781
{"abc:def:hij", false},
782782
{"abc:", false},
783+
{"123sdkKey:accesTokenWith=", true},
783784
}
784785

785786
conf := config.NewDefaultConfig()

0 commit comments

Comments
 (0)