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: replace api key with SendKey before transmission #1404

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

VinozzZ
Copy link
Contributor

@VinozzZ VinozzZ commented Oct 30, 2024

Which problem is this PR solving?

Replacing API key with the configured SendKey in the router causes peer communication to fail due to api key validation on both peer and incoming traffic.

To resolve this issue, this PR adjusts the replacement logic to occur immediately before transmission.

Short description of the changes

  • only check if the api key is acceptable in the router
  • do replacement in sendTraces

@VinozzZ VinozzZ added the type: bug Something isn't working label Oct 30, 2024
@VinozzZ VinozzZ added this to the v2.9 milestone Oct 30, 2024
@VinozzZ VinozzZ self-assigned this Oct 30, 2024
@VinozzZ VinozzZ requested a review from a team as a code owner October 30, 2024 15:03
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Looks good. Left some suggestions to improve clarity and add return error to IsAccepted

if a.AcceptOnlyListedKeys && !slices.Contains(a.ReceiveKeys, apiKey) {
err := fmt.Errorf("api key %s not found in list of authorized keys", a.sanitize(apiKey))
return "", err
func (a *AccessKeyConfig) IsAccepted(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.

I think this could be a little clearer, maybe something like IsValid instead? We should add a function description too as it's public function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, we create similar errors when this returns false so we could update this func to return the error and check if it's nil when calling it.

SendKeyMode: tt.fields.SendKeyMode,
AcceptOnlyListedKeys: tt.fields.AcceptOnlyListedKeys,
}
if got := a.IsAccepted(tt.key); got != tt.want {
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't very clear, let's separate it out a little:

Suggested change
if got := a.IsAccepted(tt.key); got != tt.want {
got := a.IsAccepted(tt.key)
if got != tt.want {

@@ -13,7 +13,7 @@ import (

// for generating request IDs
func init() {
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the change for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants