-
Notifications
You must be signed in to change notification settings - Fork 928
feat: secure and cross-domain subdomain-based proxying #4136
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
Conversation
Using the secret as the key works well 👍. Just make sure to comment the hash should be treated as a secret. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a thorough review, and I'm impressed with what you came up with. This implementation is very clean. Bravo! Just a few questions before merge.
keyID, _, hashedSecret, data := generateAPIKey(t, db) | ||
insertAPIKey(t, db, keyID, hashedSecret) | ||
|
||
encrypted, err := encryptAPIKey(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on moving encryptAPIKey
and decryptAPIKey
into a new package like appwildcard
or something and moving associated helper functions there? I like all the code, but I'm worried that someone exploring the coderd
package may not understand when or why we need to encrypt/decrypt keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A problem we had in v1 was that the devurls code was split across many different places. I'd like to avoid that if possible in v2 by keeping all of the code in one place.
I've added a comment above each of these functions, does that solve the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, that code wasn't consolidated well. Seems good to me!
Why not do this using Playwright which supports multiple browsers? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a FE view, all looks good 👍🏼
ExtractAPIKey
and turn the parameters into a struct./api/v2/applications/auth-redirect?redirect_uri=...
redirect
query parameter set) if the user is not logged in?redirect_uri=x
with?coder_application_api_key_...=$encrypted_key
?coder_application_api_key
get intercepted and not proxied.apps.coder.com
/api/v2/authcheck
because I wanted to use it in a test./api/v2/users/:userid/authorization
in favor of the aboveThe new auth flow looks like this from a network perspective:

TODO: