mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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. Backport of #16005 Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
This commit is contained in:
parent
a603c07989
commit
96d0831770
@ -178,6 +178,12 @@ func (aa *authApplierV3) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevoke
|
||||
func (aa *authApplierV3) checkLeasePuts(leaseID lease.LeaseID) error {
|
||||
lease := aa.lessor.Lookup(leaseID)
|
||||
if lease != 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 lease.Keys() {
|
||||
if err := aa.as.IsPutPermitted(&aa.authInfo, []byte(key)); err != nil {
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user