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 http node attestor #4909

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open

Add http node attestor #4909

wants to merge 53 commits into from

Conversation

kfox1111
Copy link
Contributor

@kfox1111 kfox1111 commented Feb 23, 2024

Adds an http node attestor

Fixes: #4788

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Copy link
Member

@evan2645 evan2645 left a comment

Choose a reason for hiding this comment

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

Thank you for this @kfox1111 and for your patience. I left a handful of high level comments/questions. I had many smaller comments that I held back, I think we're clear to move this out of draft and add tests etc whenever you have a chance

doc/plugin_agent_nodeattestor_httppop.md Outdated Show resolved Hide resolved
doc/plugin_agent_nodeattestor_httppop.md Outdated Show resolved Hide resolved
doc/plugin_server_nodeattestor_httppop.md Outdated Show resolved Hide resolved
pkg/agent/plugin/nodeattestor/httppop/httppop.go Outdated Show resolved Hide resolved
return &Challenge{Nonce: nonce}, nil
}

func CalculateResponse(challenge *Challenge) (*Response, error) {
Copy link
Member

Choose a reason for hiding this comment

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

What do you envision happening here? Since the challenge is fulfilled by out of band call back from the server, I don't think we need to send anything back on the stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly a copy/paste thing from other plugins that use it...

But, there does need to be a message from the agent to the server after the agent starts up the http server and hosts the token to tell the server it can now try and call it. So, there is a Response, even though its blank.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the extra function or leave it for consistency with the other plugins?

@kfox1111
Copy link
Contributor Author

@evan2645 Thanks for the review and the discussion! All good things to consider. :)

Copy link

@Paul-Luciano-2003 Paul-Luciano-2003 left a comment

Choose a reason for hiding this comment

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

helllo, just saying hi.
i have to build a better domain, pitch in for team players.

Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
@kfox1111 kfox1111 marked this pull request as ready for review May 16, 2024 22:42
@azdagron azdagron self-assigned this Jun 4, 2024
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
}

// make sure the configuration produces valid data
if _, err := loadConfigData(config); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather change it. I think it makes it all easier to reason about.

pkg/common/plugin/httpchallenge/httpchallenge.go Outdated Show resolved Hide resolved
doc/plugin_server_nodeattestor_http_challenge.md Outdated Show resolved Hide resolved
kfox1111 and others added 9 commits June 22, 2024 07:47
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Co-authored-by: Andrew Harding <azdagron@gmail.com>
Signed-off-by: kfox1111 <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Path: fmt.Sprintf("/.well-known/spiffe/nodeattestor/http_challenge/%s/challenge", attestationData.AgentName),
}

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

This timeout is probably better applied by the caller. And instead of using context.Background(), it should use the context from the RPC so that it respects stream cancellation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean, the value of the timeout should be passed to the function, or the whole context.WithTimeout should be lifted out, and its resulting context passed to this function?

pkg/common/plugin/httpchallenge/httpchallenge.go Outdated Show resolved Hide resolved
pkg/common/plugin/httpchallenge/httpchallenge.go Outdated Show resolved Hide resolved
pkg/common/plugin/httpchallenge/httpchallenge.go Outdated Show resolved Hide resolved
pkg/common/plugin/httpchallenge/httpchallenge.go Outdated Show resolved Hide resolved
u, _ := url.Parse(server.URL)
_, port, _ := net.SplitHostPort(u.Host)
oldDialContext := http.DefaultTransport.(*http.Transport).DialContext
dialContext := func(ctx context.Context, network, addr string) (net.Conn, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this special dialing? Can the hostname be "localhost" instead of "foo"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

chatted via slack about this... Maybe resolved now. Please rereview.

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
common_httpchallenge.DefaultRandReader = strings.NewReader("123456789abcdefghijklmnopqrstuvwxyz")
Copy link
Member

Choose a reason for hiding this comment

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

If possible, it's better to avoid mutating package level variables from tests. Doing so inhibits parallelizing test execution in the future.

Instead of trying to control the generated nonce, can the closure you pass in for the challenge response function update a variable that controls what is returned from the http server?

Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
kfox1111 and others added 13 commits July 19, 2024 09:51
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Co-authored-by: Andrew Harding <azdagron@gmail.com>
Signed-off-by: kfox1111 <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
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.

DNS/HTTP Node Attestor
5 participants