Files
nvke/auth/Makefile
Dan Budris f172504d8f feat(auth): authorization client, backend interface and tenant isolation check (#1943)
Add auth/authz, the authorization library NVKE APIs share. An API builds a
Query from the verified Principal, the action and the resource, and calls
Client.Authorize. The client checks the query, asks the backend, fails
closed, and maps the outcome to ErrDenied, ErrNotFound or ErrNoTenant. It
refuses an allow whose caller tenant is malformed, or missing on a resource
that isn't global, because the API records that tenant as a create's owner
and filters a list by it.

The backend owns tenancy. It reads the caller's tenant, decides who is an
operator, and calls CheckIsolation before any policy. Resource.Scope says
how a request relates to tenants: an object, a create, a list or a global
resource. CheckTenantID holds the tenant ID rules every backend shares. A
malformed caller tenant is refused even for a global resource.

authztest.Run is the conformance suite every backend must pass. A test runs
it against broken backends in child processes and requires each to fail.

Signed-off-by: dbudris <dbudris@nvidia.com>
2026-10-27 16:55:44 -04:00

46 lines
1.4 KiB
Makefile

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# This module holds the NVKE API authentication and authorization libraries
# (authn, authz). It is its own module, like controller/api, so a component
# other than the controller can import it.
GO ?= go
GOBIN ?= $(shell $(GO) env GOBIN)
ifeq (,$(GOBIN))
GOBIN = $(shell $(GO) env GOPATH)/bin
endif
# This module lints with controller/.golangci.yml, the rules its code was
# written under. It sits outside controller/, so it names the file rather than
# inheriting it. Keep workspace mode on to match the other module builds.
GOLANGCI_LINT_GOWORK :=
GOLANGCI_LINT_CONFIG := ../controller/.golangci.yml
include ../make/golangci.mk
include ../make/coverage.mk
GO_TEST_FLAGS ?=
.PHONY: help fmt lint test
##@ Help
help: ## Show the available targets.
@awk 'BEGIN { FS = ":.*## " } \
/^##@ / { printf "\n%s\n", substr($$0, 5) } \
/^[a-z][a-z0-9-]*:.*## / { printf " %-22s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo
##@ Build and test
fmt: ## Format the source with golangci-lint's formatters.
@$(GOLANGCI_LINT_RUN) fmt --config $(GOLANGCI_LINT_CONFIG) ./...
lint: ## Run golangci-lint over this module. (run by the merge gate)
@$(GOLANGCI_LINT_RUN) run --config $(GOLANGCI_LINT_CONFIG) --timeout 10m
test: ## Run this module's tests.
@$(COVERAGE_MKDIR)
$(GO) test $(GO_TEST_FLAGS) $(GO_COVER_FLAGS) ./...