Skip to content

Commit af1e088

Browse files
authored
Validate that clientId does not contain ':' (#266)
Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
1 parent e99c3eb commit af1e088

File tree

10 files changed

+161
-112
lines changed

10 files changed

+161
-112
lines changed

config/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
BUF ?= github.com/bufbuild/buf/cmd/buf@v1.17.0
15+
BUF ?= github.com/bufbuild/buf/cmd/buf@v1.32.2
1616

1717
PROTO_SOURCES := $(shell find . -name '*.proto')
1818

1919
.PHONY: build
2020
build: $(PROTO_SOURCES) ## Generate the Go code from the protobuf definitions
2121
@echo "Generating Go code from protobuf definitions"
22-
@go run $(BUF) mod update
2322
@go run $(BUF) build
2423
@go run $(BUF) generate
2524
@go mod tidy

config/buf.gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins:
2424
out: gen/go
2525
opt:
2626
- paths=source_relative
27-
- plugin: buf.build/bufbuild/validate-go
27+
- plugin: buf.build/bufbuild/validate-go:v1.0.4
2828
out: gen/go
2929
opt:
3030
- paths=source_relative

config/buf.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ deps:
44
- remote: buf.build
55
owner: envoyproxy
66
repository: protoc-gen-validate
7-
commit: 6607b10f00ed4a3d98f906807131c44a
8-
digest: shake256:acc7b2ededb2f88d296862943a003b157bdb68ec93ed13dcd8566b2d06e47993ea6daf12013b9655658aaf6bbdb141cf65bfe400ce2870f4654b0a5b45e57c09
7+
commit: daf171c6cdb54629b5f51e345a79e4dd
8+
digest: shake256:4ae167d7eed10da5f83a3f5df8c670d249170f11b1f2fd19afda06be2cff4d47dcc95e9e4a15151ecc8ce2d3d3614caf9a04d3ad82fb768a3870dedfa9455f36

config/buf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
version: v1
1616
name: buf.build/authservice/config
1717
deps:
18-
- buf.build/envoyproxy/protoc-gen-validate:6607b10f00ed4a3d98f906807131c44a
18+
- buf.build/envoyproxy/protoc-gen-validate
1919
lint:
2020
use:
2121
- DEFAULT

config/gen/go/v1/oidc/config.pb.go

Lines changed: 106 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/gen/go/v1/oidc/config.pb.validate.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/v1/oidc/config.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ message OIDCConfig {
132132
// The OIDC client ID assigned to the filter to be used in the
133133
// [Authentication Request](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest).
134134
// Required.
135-
string client_id = 5 [(validate.rules).string.min_len = 1];
135+
// The client ID is used to authenticate to the Token endpoint using HTTP Basic Auth and it
136+
// must not contain a colon (":") character.
137+
string client_id = 5 [(validate.rules).string = {min_len: 1, not_contains: ":"}];
136138

137139
// This message defines a reference to a Kubernetes Secret resource.
138140
message SecretReference {

env.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NAME ?= authservice
1818

1919
-include $(ROOT)/.makerc # Pick up any local overrides.
2020

21-
GOLANGCI_LINT ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3
21+
GOLANGCI_LINT ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
2222
GOSIMPORTS ?= github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8
2323
LICENSER ?= github.com/liamawhite/licenser@v0.6.1-0.20210729145742-be6c77bf6a1f
2424
KIND ?= sigs.k8s.io/kind@v0.18.0

internal/config_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ func (e errCheck) Check(t *testing.T, err error) {
4747
}
4848
}
4949

50-
const msgLengthValidation = "value length must be at least 1 runes"
50+
const (
51+
msgLengthValidation = "value length must be at least 1 runes"
52+
msgInvalidClientID = `invalid OIDCConfig.ClientId: value contains substring ":"`
53+
)
5154

5255
func TestValidateConfig(t *testing.T) {
5356
tests := []struct {
@@ -64,6 +67,7 @@ func TestValidateConfig(t *testing.T) {
6467
{"multiple-oidc", "testdata/multiple-oidc.json", errCheck{is: ErrMultipleOIDCConfig}},
6568
{"invalid-redis", "testdata/invalid-redis.json", errCheck{is: ErrInvalidURL}},
6669
{"invalid-oidc-uris", "testdata/invalid-oidc-uris.json", errCheck{is: ErrRequiredURL}},
70+
{"invalid-oidc-client-id", "testdata/invalid-oidc-client-id.json", errCheck{msg: msgInvalidClientID}},
6771
{"invalid-health-port", "testdata/invalid-health-port.json", errCheck{is: ErrHealthPortInUse}},
6872
{"invalid-callback-uri", "testdata/invalid-callback.json", errCheck{is: ErrMustNotBeRootPath}},
6973
{"invalid-logout-path", "testdata/invalid-logout.json", errCheck{is: ErrMustNotBeRootPath}},
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"listen_address": "0.0.0.0",
3+
"listen_port": 8080,
4+
"log_level": "debug",
5+
"chains": [
6+
{
7+
"name": "oidc",
8+
"filters": [
9+
{
10+
"oidc": {
11+
"configuration_uri": "http://fake",
12+
"callback_uri": "http://fake/callback",
13+
"proxy_uri": "http://fake",
14+
"jwks": "fake-jwks",
15+
"client_id": "invalid:clientId",
16+
"client_secret": "fake-client-secret",
17+
"id_token": {
18+
"preamble": "Bearer",
19+
"header": "authorization"
20+
},
21+
"redis_session_store_config": {
22+
"server_uri": "redis://localhost:6379/0"
23+
},
24+
"skip_verify_peer_cert": true
25+
}
26+
}
27+
]
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)