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

fix: check apikeys for otlp requests too (+tests) #672

Merged
merged 3 commits into from
Apr 28, 2023

Conversation

kentquirk
Copy link
Contributor

Which problem is this PR solving?

Short description of the changes

  • Refactor middleware to pull out the key-validation logic
  • Use it in the http middleware
  • Call it in the OTLP handler
  • Add a normal (mocked) test for OTLP
  • Add an integration test for HTTP

@kentquirk kentquirk requested a review from a team as a code owner April 27, 2023 23:07
@@ -37,6 +37,25 @@ func (r *Router) queryTokenChecker(next http.Handler) http.Handler {
})
}

func (r *Router) isKeyAllowed(key string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is called on every request, it could be nice to be able to check the key in a map instead of looping through a slice each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing that would require changing the data type of the config value to a map, and writing code that parses the current configuration into it both on initial load and on reload. It's a good idea, but it's something that a) we've already lived with for a long time, b) in practice might even be more expensive because most installations just have ["*"] as the value, and c) and I'd rather do it as a separate issue as part of the config rework.

@kentquirk kentquirk merged commit a50515a into main Apr 28, 2023
@kentquirk kentquirk deleted the kent.check_keys_fix branch April 28, 2023 18:59
kentquirk added a commit that referenced this pull request May 8, 2023
## Which problem is this PR solving?

- #671 -- Refinery's APIKeys configuration value was not being used for
OTel requests

## Short description of the changes

- Refactor middleware to pull out the key-validation logic
- Use it in the http middleware
- Call it in the OTLP handler
- Add a normal (mocked) test for OTLP
- Add an integration test for HTTP
kentquirk added a commit that referenced this pull request May 8, 2023
## Which problem is this PR solving?

- #671 -- Refinery's APIKeys configuration value was not being used for
OTel requests

## Short description of the changes

- Refactor middleware to pull out the key-validation logic
- Use it in the http middleware
- Call it in the OTLP handler
- Add a normal (mocked) test for OTLP
- Add an integration test for HTTP
kentquirk added a commit that referenced this pull request May 8, 2023
## Which problem is this PR solving?

- #671 -- Refinery's APIKeys configuration value was not being used for
OTel requests

## Short description of the changes

- Refactor middleware to pull out the key-validation logic
- Use it in the http middleware
- Call it in the OTLP handler
- Add a normal (mocked) test for OTLP
- Add an integration test for HTTP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants