-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Move supervisor API request handlers into dedicated package and add unit tests #11471
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11471 +/- ##
==========================================
- Coverage 48.44% 45.03% -3.41%
==========================================
Files 181 184 +3
Lines 18809 18996 +187
==========================================
- Hits 9112 8555 -557
- Misses 8348 9225 +877
+ Partials 1349 1216 -133
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Moving to draft for addition of tests |
d086dd9
to
c973c3d
Compare
c973c3d
to
e9299a8
Compare
e9299a8
to
b82d0f4
Compare
b82d0f4
to
af37eb7
Compare
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 think this is a big security improvement (and testing!)
func NewHandler(ctx context.Context, control *config.Control, cfg *cmds.Server) http.Handler { | ||
nodeAuth := nodepassword.GetNodeAuthValidator(ctx, control) | ||
|
||
prefix := "/v1-{program}" |
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'm curious: How is this {program}
var populated?
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.
In this format it is just a placeholder for mux to match the request path. It is used as a var in the request handlers and must match the program name for RBAC purposes.
65cec0a
to
93f5e42
Compare
The servers package, and router.go in particular, had become quite large. Address this by moving some things out to separate packages: * http request handlers all move to pkg/server/handlers. * node password bootstrap auth handler goes into pkg/nodepassword with the other nodepassword code. While we're at it, also be more consistent about calling variables that hold a config.Control struct or reference `control` instead of `config` or `server`. Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Brad Davidson <[email protected]>
Clients now generate keys client-side and send CSRs. If the server is down-level and sends a cert+key instead of just responding with a cert signed with the client's public key, we use the key from the server instead. Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Brad Davidson <[email protected]>
Convert nodepassword tests to use shared mocks Signed-off-by: Brad Davidson <[email protected]>
Make this field an interface instead of pointer to allow mocking. Not sure why wrangler has a type that returns an interface instead of just making it an interface itself. Wrangler in general is hard to mock for testing. Signed-off-by: Brad Davidson <[email protected]>
Signed-off-by: Brad Davidson <[email protected]>
93f5e42
to
eb8144a
Compare
Proposed Changes
Handles a corner case revealed by testing supervisor APIs
Moves request handlers and bootstrap password validation code out of the
server
package into dedicated packages.Improves overall security posture by no longer reusing private keys for agent certificates across multiple nodes in the cluster. Both agent and server contain backwards-compatibility code to allow interop with other version that do not support certificate signing requests when acquiring agent certs.
After upgrading, existing nodes can be re-keyed to use unique keys by deleting their existing certs and keys from disk or running
k3s certificate rotate
, and restarting the node.This also removes the requirement to rotate certs on servers before agents, since they no longer reuse certs+keys pre-generated by the server. Agent certs will in fact be renewed (with the same key) on every startup. Rotation will work as it currently does, where the keys are removed to force creation of new keys and certs.
Types of Changes
tech debt / enhancement
Verification
Testing
Yes
Linked Issues
User-Facing Change
Further Comments