Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filters/auth: add host opt-out to jwtMetrics and oauthTokeninfoValidate #3164

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

AlexanderYastrebov
Copy link
Member

Extend configuration of jwtMetrics and oauthTokeninfoValidate to support opt-out by request host pattern - disable metrics collection and validation when request host matches any of the configured opt-out regular expressions.

This can be used to exclude internal cluster domain (*.ingress.cluster.local hosts).

@AlexanderYastrebov AlexanderYastrebov added the major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs label Jul 24, 2024
@AlexanderYastrebov AlexanderYastrebov force-pushed the filters/auth/opt-out-hosts branch 2 times, most recently from c4ecdea to 003f91c Compare July 24, 2024 11:50
{
name: "no metrics when host matches opted-out domain",
filters: `jwtMetrics("{issuers: [foo, bar], optOutHosts: [ '^.+[.]domain[.]test$', '^exact[.]test$' ]}")`,
request: &http.Request{Method: "GET", Host: "foo.domain.test"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test the same filter, but with "domain.test" host?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can but the goal is not to test regexp itself or all edge cases but the logic when host matches any or none of the configured patterns.

filters/auth/jwt_metrics_test.go Show resolved Hide resolved
filters/auth/tokeninfo_test.go Show resolved Hide resolved
filters/auth/tokeninfo_test.go Show resolved Hide resolved
Extend configuration of `jwtMetrics` and `oauthTokeninfoValidate`
to support opt-out by request host pattern - disable metrics collection and validation
when request host matches any of the configured opt-out regular expressions.

This can be used to exclude internal cluster domain (*.ingress.cluster.local hosts).

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
@AlexanderYastrebov AlexanderYastrebov force-pushed the filters/auth/opt-out-hosts branch from 003f91c to 755df3d Compare July 24, 2024 12:57
@RomanZavodskikh
Copy link
Contributor

👍

1 similar comment
@AlexanderYastrebov
Copy link
Member Author

👍

@AlexanderYastrebov AlexanderYastrebov merged commit 0be9447 into master Jul 24, 2024
17 checks passed
@AlexanderYastrebov AlexanderYastrebov deleted the filters/auth/opt-out-hosts branch July 24, 2024 13:17
require.Equal(t, spec.Name(), f.Name)

_, err := spec.CreateFilter(f.Args)
t.Logf("%v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not assert.Error show the same thing?

Copy link
Member Author

@AlexanderYastrebov AlexanderYastrebov Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think assert.Error does not log the error, only checks that is not nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants