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

chore(auth): Exclude URL from auth check as it can differ between environments #1142

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

ram-senth
Copy link
Member

By using URL as part of the payload that is signed we are assuming that URL used by client will be same as the URL seen in the request payload on Seer end. This is not true as requests from Subscription processor has full UTL including server name while those from the UI do not.

This PR makes URL optional. This will be step 1 of the fix. We need to follow this up with two more changes:

  • remove URL from all locations on the client end where we are signing Seer requests
  • once we confirm that Seer is not getting requests with URL anymore, then remove the code that checks for URL + payload.

@ram-senth ram-senth force-pushed the anomaly_detection/exclude_url_from_auth branch from b567ec8 to 17f1b48 Compare September 9, 2024 16:53
if nonce:
if is_valid(b"%s:%s" % (nonce.encode(), body), key, signature_data):
sentry_sdk.metrics.incr(
key="rpc_signature_auth_success", value=1, tags={"with_url": False}
Copy link
Member Author

Choose a reason for hiding this comment

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

Change the key and value to {"additional_payload": "nonce"}? Similarly change line 193 to {"additional_payload": "url"}?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can also make the change if you are ok with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have removed use of metrics API and changed the key-value pairs.

@@ -88,7 +88,10 @@ def wrapper(config: AppConfig = injected) -> Any:
# Optional for now during rollout, make this required after rollout.
if auth_header.startswith("Rpcsignature "):
parts = auth_header.split()
if len(parts) != 2 or not compare_signature(request.url, raw_data, parts[1]):
sentry_sdk.metrics.incr(key="rpc_signature_auth_attempt", value=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

metrics API is being deprecated, so you would want to switch it out for a span + span metric (e.g.

seer/src/seer/app.py

Lines 108 to 109 in f393fef

with sentry_sdk.start_span(op="seer.grouping", description="grouping lookup") as span:
sentry_sdk.set_tag("read_only", data.read_only)
)

you can also do this to reference the current span

span = sentry_sdk.Hub.current.scope.span

Copy link
Member Author

Choose a reason for hiding this comment

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

Used the second option to update existing span.

@ram-senth ram-senth merged commit ec794e1 into main Sep 10, 2024
11 checks passed
@ram-senth ram-senth deleted the anomaly_detection/exclude_url_from_auth branch September 10, 2024 00:29
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.

3 participants