mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmauth: simplify configuration for src_query_args
Use the shorter form: src_query_args: - arg1=value1 - arg2=value2 instead of src_query_args: - name: arg1 value: value2 - name: arg2 value: value2 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5878
This commit is contained in:
parent
97dd7e26ad
commit
8efe12d66e
3 changed files with 27 additions and 16 deletions
|
@ -163,13 +163,36 @@ type URLMap struct {
|
|||
|
||||
// Regex represents a regex
|
||||
type Regex struct {
|
||||
sOriginal string
|
||||
re *regexp.Regexp
|
||||
|
||||
sOriginal string
|
||||
}
|
||||
|
||||
// QueryArg represents HTTP query arg
|
||||
type QueryArg struct {
|
||||
Name string `yaml:"name"`
|
||||
Value string `yaml:"value,omitempty"`
|
||||
|
||||
sOriginal string
|
||||
}
|
||||
|
||||
// UnmarshalYAML unmarshals up from yaml.
|
||||
func (qa *QueryArg) UnmarshalYAML(f func(interface{}) error) error {
|
||||
if err := f(&qa.sOriginal); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
n := strings.IndexByte(qa.sOriginal, '=')
|
||||
if n >= 0 {
|
||||
qa.Name = qa.sOriginal[:n]
|
||||
qa.Value = qa.sOriginal[n+1:]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalYAML marshals up to yaml.
|
||||
func (qa *QueryArg) MarshalYAML() (interface{}, error) {
|
||||
return qa.sOriginal, nil
|
||||
}
|
||||
|
||||
// URLPrefix represents passed `url_prefix`
|
||||
|
|
|
@ -218,15 +218,6 @@ users:
|
|||
- src_query_args: abc
|
||||
url_prefix: http://foobar
|
||||
`)
|
||||
f(`
|
||||
users:
|
||||
- username: a
|
||||
url_map:
|
||||
- src_query_args:
|
||||
- name: foo
|
||||
incorrect_value: bar
|
||||
url_prefix: http://foobar
|
||||
`)
|
||||
|
||||
// Invalid headers in url_map (missing ':')
|
||||
f(`
|
||||
|
@ -350,8 +341,7 @@ users:
|
|||
- src_paths: ["/api/v1/write"]
|
||||
src_hosts: ["foo\\.bar", "baz:1234"]
|
||||
src_query_args:
|
||||
- name: foo
|
||||
value: bar
|
||||
- 'foo=bar'
|
||||
url_prefix: ["http://vminsert1/insert/0/prometheus","http://vminsert2/insert/0/prometheus"]
|
||||
headers:
|
||||
- "foo: bar"
|
||||
|
|
|
@ -125,12 +125,10 @@ while routing requests with `db=bar` query arg to `http://app2-backend`:
|
|||
unauthorized_user:
|
||||
url_map:
|
||||
- src_query_args:
|
||||
- name: db
|
||||
value: foo
|
||||
- "db=foo"
|
||||
url_prefix: "http://app1-backend/"
|
||||
- src_query_args:
|
||||
- name: db
|
||||
value: bar
|
||||
- "db=bar"
|
||||
url_prefix: "http://app2-backend/"
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue