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

Only return specific identity types from /1.0/certificates #14199

Merged
merged 13 commits into from
Oct 4, 2024

Conversation

markylaing
Copy link
Contributor

In the specification for fine-grained authorization for TLS clients, the /1.0/certificates API does not return identities of the new type (because they can't be managed via this API).

In the PoC PR (#14099) this is done in a bit of a hacky way. They are essentially filtered out because they don't have a matching certificate type.

This PR does this in a more correct way, by ensuring that certificate database queries only return identities of the correct type. I've done some additional clean up as well.

@markylaing markylaing self-assigned this Oct 3, 2024
@markylaing markylaing marked this pull request as ready for review October 3, 2024 17:55
@markylaing markylaing changed the title Certificate db follow up Only specific entity types from /1.0/certificates Oct 3, 2024
@markylaing markylaing changed the title Only specific entity types from /1.0/certificates Only return specific identity types from /1.0/certificates Oct 4, 2024
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Do we also need to delete type CertificateFilter?

@markylaing
Copy link
Contributor Author

Do we also need to delete type CertificateFilter?

Probably yes. I'll double check.

Currently all Certificate methods are getting all identities whose
authentication method is "tls". When we add fine-grained TLS identities
we don't want to expose these via the certificate API. Rather than
filtering these out in the API handlers, this statement can be used to
only get the certificates we want from the database.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
…dentities.

Note that the `GetCertificates` function is never called with a
filter.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
This function is only called in one place with `certificate.TypeServer`.
So we don't need to handle the other cases.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
This can be replaced with a call to `DeleteIdentitys`.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
This function shouldn't be defined on the `*DB` as we're moving as much
as possible to just use a `*sql.Tx`. It also isn't making use of the
provided `context.Context` argument. Lastly, it is only called in one place
so we can just move the transaction to the call site.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
This function is already a helper function and `UpdateCertificate` was
only called here.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
@tomponline
Copy link
Member

Thanks

@tomponline tomponline merged commit 222fff0 into canonical:main Oct 4, 2024
27 of 28 checks passed
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.

2 participants