diff --git a/api/v3rpc/rpctypes/error.go b/api/v3rpc/rpctypes/error.go index 781c73b7bff..e639345c52f 100644 --- a/api/v3rpc/rpctypes/error.go +++ b/api/v3rpc/rpctypes/error.go @@ -68,6 +68,7 @@ var ( ErrGRPCPermissionNotGiven = status.Error(codes.InvalidArgument, "etcdserver: permission not given") ErrGRPCPermissionDenied = status.Error(codes.PermissionDenied, "etcdserver: permission denied") ErrGRPCRoleNotGranted = status.Error(codes.FailedPrecondition, "etcdserver: role is not granted to the user") + ErrGRPCRootRoleNotGranted = status.Error(codes.FailedPrecondition, "etcdserver: permission denied, root role is not granted to current user") ErrGRPCPermissionNotGranted = status.Error(codes.FailedPrecondition, "etcdserver: permission is not granted to the role") ErrGRPCAuthNotEnabled = status.Error(codes.FailedPrecondition, "etcdserver: authentication is not enabled") ErrGRPCInvalidAuthToken = status.Error(codes.Unauthenticated, "etcdserver: invalid auth token") @@ -138,6 +139,7 @@ var ( ErrorDesc(ErrGRPCAuthFailed): ErrGRPCAuthFailed, ErrorDesc(ErrGRPCPermissionDenied): ErrGRPCPermissionDenied, ErrorDesc(ErrGRPCRoleNotGranted): ErrGRPCRoleNotGranted, + ErrorDesc(ErrGRPCRootRoleNotGranted): ErrGRPCRootRoleNotGranted, ErrorDesc(ErrGRPCPermissionNotGranted): ErrGRPCPermissionNotGranted, ErrorDesc(ErrGRPCAuthNotEnabled): ErrGRPCAuthNotEnabled, ErrorDesc(ErrGRPCInvalidAuthToken): ErrGRPCInvalidAuthToken, @@ -205,6 +207,7 @@ var ( ErrAuthFailed = Error(ErrGRPCAuthFailed) ErrPermissionDenied = Error(ErrGRPCPermissionDenied) ErrRoleNotGranted = Error(ErrGRPCRoleNotGranted) + ErrRootRoleNotGranted = Error(ErrGRPCRootRoleNotGranted) ErrPermissionNotGranted = Error(ErrGRPCPermissionNotGranted) ErrAuthNotEnabled = Error(ErrGRPCAuthNotEnabled) ErrInvalidAuthToken = Error(ErrGRPCInvalidAuthToken) diff --git a/server/etcdserver/api/v3rpc/util.go b/server/etcdserver/api/v3rpc/util.go index 2354b0cb243..1b03d1ef989 100644 --- a/server/etcdserver/api/v3rpc/util.go +++ b/server/etcdserver/api/v3rpc/util.go @@ -83,6 +83,7 @@ var toGRPCErrorMap = map[error]error{ auth.ErrPermissionNotGiven: rpctypes.ErrGRPCPermissionNotGiven, auth.ErrPermissionDenied: rpctypes.ErrGRPCPermissionDenied, auth.ErrRoleNotGranted: rpctypes.ErrGRPCRoleNotGranted, + auth.ErrRootRoleNotGranted: rpctypes.ErrGRPCRootRoleNotGranted, auth.ErrPermissionNotGranted: rpctypes.ErrGRPCPermissionNotGranted, auth.ErrAuthNotEnabled: rpctypes.ErrGRPCAuthNotEnabled, auth.ErrInvalidAuthToken: rpctypes.ErrGRPCInvalidAuthToken,