-
Notifications
You must be signed in to change notification settings - Fork 62
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
Use a mux #115
base: main
Are you sure you want to change the base?
Use a mux #115
Conversation
Hi. This looks reasonable, though can you elaborate on the use case (which sounds interesting)? |
I'm writing a windows ssh agent that automatically uses vault to sign ssh public keys and then loads those ssh certificates. The necessary vault token is gotten by the Users can then chose to renew those certificates in the interface, this again fires the same oidc login flow to get a new token to sign the new generated ssh pub/priv keys |
After testing, some more changes were needed:
Lines 106 to 108 in 175b36b
Lines 98 to 103 in 175b36b
|
Can I do anything to get this merged? Any issues with this PR? |
Any maintainer that can take a look? |
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.
Hi @42wim. I'm going to have a look and test this out. I understand that it's helpful for how you're planning to use this. I'd like to understand if there are any undesired changes for most using the regular CLI workflow. Thanks!
mux.HandleFunc("/oidc/callback", callbackHandler(c, mount, clientNonce, doneCh)) | ||
srv := &http.Server{Handler: mux} | ||
srv.SetKeepAlivesEnabled(false) | ||
defer srv.Close() | ||
|
||
listener, err := net.Listen("tcp", listenAddress+":"+port) |
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.
Trying to understand your use case a bit more -- Are you doing something to avoid port collision? I have to imagine so if you were hitting the "multiple registrations" issue.
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.
This is used in a long running process, like mentioned above:
"I'm writing a windows ssh agent that automatically uses vault to sign ssh public keys and then loads those ssh certificates. The necessary vault token is gotten by the Auth function.
Users can then chose to renew those certificates in the interface, this again fires the same oidc login flow to get a new token to sign the new generated ssh pub/priv keys"
I've made a POC about the issue, see https://gist.github.com/42wim/e97d4dbf9d61ccfe436f535660d9c069
Running this with the current code, will give you panic: http: multiple registrations for /oidc/callback
Because it cannot re-register the same pattern in the default mux
https://github.com/golang/go/blob/a031f4ef83edc132d5f49382bfef491161de2476/src/net/http/server.go#L2529-L2531
This is not an issue in the CLI where you only run this once and it exits, but when running multiple times in a daemon/client app it is :)
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.
This behaviour 100% matches what's seen in the official Terraform provider for Vault - hashicorp/terraform-provider-vault#2131
I think maintainers should definitely look at it, since it affects their own product :)
Use a new mux instead of the default one so that the
Auth
method can be used in long-running programs.This fixes the
panic: http: multiple registrations for /oidc/callback
when runningAuth
again.