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

uuid endpoint #39

Merged
merged 1 commit into from
Oct 18, 2021
Merged

uuid endpoint #39

merged 1 commit into from
Oct 18, 2021

Conversation

giggsoff
Copy link
Collaborator

Implementation of the /uuid endpoint #38

Signed-off-by: Petr Fedchenkov [email protected]

Copy link
Contributor

@deitch deitch left a comment

Choose a reason for hiding this comment

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

Some questions, other than that, looking good.

http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
cert, err := parseX509Cert(uuidRequest.GetDeviceCert())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using this new parseX509Cert() func, and not the existing getClientCert() that all of the others use? Is this different somehow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, you need to take the certificate from the UuidRequest object, not from the request itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that documented somewhere? Is this fundamentally different than all the other requests?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the V2 API I'd expect the full client cert to be in the authcontainer. If we also have it in the UuidRequest it means that for V2 we'd have it in two places; either they need to be checked to be identical or we don't use the UuidRequest DeviceCert (latter would make the message a lot smaller.)

If we support the uuid API endpoint in the V1 API it means we do need the DeviceCert in the uuid request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, we need to add check that the TLS cert is the same with DeviceCert inside UuidRequest?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not clear on this. Is /uuid v1 or v2? If it is v1, then the device cert needs to be available via mTLS. If it is v2, we should just defer on adding /uuid until adam goes v2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhat related question, but for the other APIs (config, metrics, info) where we have a UUID in the URL and one which we fetch based on the cert, does Adam/Eden check that they match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems we do not use/check uuid from url (only uuid of apps).

}

//parseX509Cert parses incoming certificate
func parseX509Cert(inp []byte) (*x509.Certificate, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Either the cert needs to be removed from the uuid message and you get the cert from the authcontainer, or you need to check that the cert in the uuid message and the authcontainer are identical.

Copy link
Contributor

Choose a reason for hiding this comment

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

Coming back to the earlier conversation, isn't authcontainer an entirely v2 construct? We should use defer on this until we get adam to v2.

http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
if u.String() != uuidTLS.String(){
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a check for a uuid match for certificates from TLS and from uuidRequest

@cshari-zededa
Copy link

@giggsoff can you please hold off from merging this, since there is a namespace conflict in python generated protofiles (due to uuid namespace collision), for which I need to move uuid/uuid.proto to eveuuid/eveuuid.proto.

@giggsoff giggsoff changed the title uuid endpoint [WIP] uuid endpoint Aug 19, 2020
@giggsoff giggsoff changed the title [WIP] uuid endpoint uuid endpoint Feb 10, 2021
@rvs
Copy link
Contributor

rvs commented Oct 18, 2021

So I see this is worked on again. Is the idea to merge it this time @giggsoff ?

@giggsoff
Copy link
Collaborator Author

Yes, seems we need this PR for lf-edge/eve#2330 (comment)

Copy link
Contributor

@rvs rvs left a comment

Choose a reason for hiding this comment

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

LGTM, but any chance you can add a unit test?

@giggsoff
Copy link
Collaborator Author

LGTM, but any chance you can add a unit test?

Added. I can see some problems with redis tests. Will work on them in another PR.

Copy link
Contributor

@rvs rvs left a comment

Choose a reason for hiding this comment

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

Perfect! @deitch -- can you give it a quick look?

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM
My question was about the generic handing of a uuid in the URL and a uuid derived from the client cert in the authcontainer and not related to this PR.

@eriknordmark eriknordmark merged commit 039c59a into lf-edge:master Oct 18, 2021
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.

5 participants