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

Add callback support to kryptoEcMiddleware #1303

Merged
merged 8 commits into from
Sep 6, 2023

Conversation

directionless
Copy link
Contributor

Problem

Sometimes we see a browser able to make requests to http://localhost, but unable to meaningfully work with the response. This breaks agent detection in the device trust flow.

Solution

One solution is to setup a simple callback. The intent here, is to allow K2 to set a URL to post back to, and then kryptoEcMiddleware can post the response to it.

This should be reasonable secure -- the callback URL is inside the krypto box, and the response is the same as what we'd send via PNG. eg: it's all opaque crypto data. There are a couple of small exceptions...

  1. We include the user agent headers
  2. we send errors

I first tried implementing this in middleware, but it was messy. First, because the url comes out of the box, so that has to be passed from the inner layer up to the outer layer. Second, because the outer layer works with readers, so there's a bunch of extra io teeing. It's much simpler this way.

@directionless
Copy link
Contributor Author

@James-Pickett This is in draft since the corresponding K2 side isn't merged, but how's the shape look to you?

James-Pickett
James-Pickett previously approved these changes Aug 29, 2023
Copy link
Contributor

@James-Pickett James-Pickett left a comment

Choose a reason for hiding this comment

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

This code looks good to me. Would like a little clarification on the goal of this thought, is it just so we can report errors back up to k2?

@directionless directionless marked this pull request as ready for review September 5, 2023 17:02
@directionless directionless added this pull request to the merge queue Sep 6, 2023
Merged via the queue into kolide:main with commit 411a5b6 Sep 6, 2023
24 checks passed
@directionless directionless deleted the seph/callbacks branch September 6, 2023 03:01
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