Early exit auth check on lease puts
Mitigates #15993 by not checking each key individually for permission when auth is entirely disabled or admin user is calling the method. Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
This commit is contained in:
@ -125,6 +125,12 @@ func (aa *authApplierV3) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevoke
|
|||||||
func (aa *authApplierV3) checkLeasePuts(leaseID lease.LeaseID) error {
|
func (aa *authApplierV3) checkLeasePuts(leaseID lease.LeaseID) error {
|
||||||
l := aa.lessor.Lookup(leaseID)
|
l := aa.lessor.Lookup(leaseID)
|
||||||
if l != nil {
|
if l != nil {
|
||||||
|
// early return for most-common scenario of either disabled auth or admin user.
|
||||||
|
// IsAdminPermitted also checks whether auth is enabled
|
||||||
|
if err := aa.as.IsAdminPermitted(&aa.authInfo); err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, key := range l.Keys() {
|
for _, key := range l.Keys() {
|
||||||
if err := aa.as.IsPutPermitted(&aa.authInfo, []byte(key)); err != nil {
|
if err := aa.as.IsPutPermitted(&aa.authInfo, []byte(key)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user