-
Notifications
You must be signed in to change notification settings - Fork 929
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
Auth: Use util for determining if the caller is a server administrator #13703
Auth: Use util for determining if the caller is a server administrator #13703
Conversation
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 looks a lot cleaner. Tests are failing though
Yeah marked as draft and fixing now. |
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Additionally, rename `IsRootUserFromCtx` to `IsServerAdmin`. 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>
When fine-grained authorization is enabled for TLS users, we will introduce a new certificate type for which the "restricted" and "project" fields will be considered deprecated. This simplifies permission management for these users. These two for loops granted operator permission in each project in the identities' project list. They were added in preparation for TLS fine-grained auth under the erroneous assumption that fine-grained auth would be enabled alongside existing TLS auth methods, which will not be the case. 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>
When `core.trust_ca_certificates` is enabled, we check the identity cache for a certificate with a matching fingerprint anyway. This is in case the certificate does exist in the truststore and was previously restricted. If the caller erroneously uses the new authentication method `auth.AuthenticationMethodPKI` instead of `api.AuthenticationMethodTLS` the identity will not be found in the cache. Returning a Not Found error in this instance tells the authorizer that they should have admin privileges! Adding validation on the authentication method when getting or setting cache entries will surface these errors more transparently. Signed-off-by: Mark Laing <mark.laing@canonical.com>
b0863b4
to
365078f
Compare
@markylaing cool what was the issue in the end? |
Ah yes I meant to update you. It was a little bit insidious actually. In the new util The fix was to use The last two commits move the |
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.
Excellent thanks
This avoids repeating similar logic in multiple places by additionally checking the identity cache for unrestricted clients when checking for admin privileges. See #13702 (comment)