Anonymous access is enabled in every example compose file, and that is the security fact to internalise first. AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' means anyone who can reach port 8080 can read, write and delete everything, including dropping collections. It is convenient for a laboratory and it is how self-hosted Weaviate instances end up exposed. Turn it off, and bind to a private interface.
Authentication has two mechanisms. API keys are simple: a list of keys mapped to user identities in the configuration. OIDC integrates with an identity provider, which is the right answer for human access and for anything needing central identity. Both can be enabled together, which is the usual production shape - keys for services, OIDC for people.
RBAC exists in recent versions and is more capable than a vector store needs to be, in a useful way: roles with permissions scoped to collections, tenants and operation types - read, write, create, delete, schema management, backup, cluster administration. The practical shape: a role per service with only the collections and operations it needs; a read-only role for reporting; an administrative role held by nobody by default. Check your version's support, because it has moved recently, and where RBAC is unavailable the honest position is that API keys map to users with coarse rights and authorisation is your application's responsibility - which the design must state rather than imply.
Tenant isolation is stronger here than a namespace design, for the reason Module 3 established: every query requires a tenant, so omitting it is an error rather than a silent cross-tenant read. Combined with RBAC scoping a role to specific tenants, that is genuine platform-enforced isolation. Still write the single code path that derives the tenant from the authenticated identity, because a code path that takes a tenant from a request parameter is as wrong here as anywhere - but note that the failure mode is better: a wrong tenant returns the wrong data, and a missing tenant returns an error.
TLS terminates at Weaviate or at a proxy in front of it, and in a cluster the inter-node traffic deserves encryption for the same reason as every other distributed database in this programme.
Monitoring is a Prometheus endpoint at /metrics, and the Weaviate-specific set is worth knowing: object counts and vector index sizes per collection and shard, the vector index queue length (which tells you indexing is falling behind an import), query latency by type, the import rate and the vectoriser's own latency, memory usage against the container limit, and the shard status per node. Add a scheduled relevance measurement, exactly as in the Pinecone course, because it remains the only check that detects a degradation the database will never report.
Sizing comes from the Module 4 measurements. Resident memory per vector at your chosen quantisation, multiplied by your object count, multiplied by the replication factor, plus the inverted index and the object store, plus headroom for imports and query working set. The honest statement: an HNSW deployment is sized by memory, and the quantisation decision is therefore the cost decision - which is why Module 4's table is also the capacity plan. Self-hosted against Weaviate Cloud is then a comparison of that hardware cost against the managed price plus what you are not operating.
Laboratory exercise 6 - make it defensible.
Demonstrate the default: with anonymous access enabled, connect from another container and drop a collection. Then disable it and show the same attempt refused. Do this in an isolated lab network.
Configure API key authentication for services and OIDC for human access if you can run an identity provider.
Implement least privilege with RBAC if your version supports it: a service role with read and write on one collection; a reporting role with read only; a role scoped to specific tenants; and an administrative role granted to nobody. Test every denial. If RBAC is unavailable, document the coarse key mapping and the application-layer design that compensates.
Implement the single tenant code path, then demonstrate both failure modes: a wrong tenant from a request parameter returning the wrong data, and a missing tenant returning an error. Contrast that with the Pinecone namespace behaviour.
Configure TLS and verify it, including inter-node.
Configure Prometheus monitoring with every metric above and a threshold for each, including the vector index queue length and a scheduled relevance check.
Then produce the sizing and cost plan from your Module 4 measurements, with a self-hosted against Weaviate Cloud comparison.
Deliverable: the anonymous access demonstration, the authentication configuration, the RBAC definitions with every denial tested (or the documented limitation), the tenant code path with both failure modes demonstrated, the TLS verification, the alert definitions including the relevance check, and the sizing and cost plan with the managed comparison.
# ==================================================================
# *** ANONYMOUS ACCESS IS ENABLED IN EVERY EXAMPLE COMPOSE FILE. ***
# ==================================================================
# AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
#
# Which means ANYONE WHO CAN REACH PORT 8080 CAN READ, WRITE AND
# DELETE EVERYTHING - INCLUDING DROPPING COLLECTIONS.
#
# Convenient for a laboratory, and *** IT IS HOW SELF-HOSTED
# WEAVIATE INSTANCES END UP EXPOSED. *** Demonstrate it in an
# ISOLATED LAB NETWORK:
# from another container, with no credentials:
# client = weaviate.connect_to_custom(http_host="weaviate", ...)
# client.collections.delete("Product")
# -> gone.
#
# *** TURN IT OFF, AND BIND TO A PRIVATE INTERFACE. ***
# ==================================================================
# AUTHENTICATION: two mechanisms, usually both.
# ==================================================================
# environment:
# AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'
#
# # API KEYS - for SERVICES:
# AUTHENTICATION_APIKEY_ENABLED: 'true'
# AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'svc-search-key,svc-ingest-key,ro-report-key'
# AUTHENTICATION_APIKEY_USERS: 'search@svc,ingest@svc,report@svc'
#
# # OIDC - for PEOPLE, and anything needing central identity:
# AUTHENTICATION_OIDC_ENABLED: 'true'
# AUTHENTICATION_OIDC_ISSUER: 'https://idp.example.test/'
# AUTHENTICATION_OIDC_CLIENT_ID: 'weaviate'
# AUTHENTICATION_OIDC_USERNAME_CLAIM: 'email'
# AUTHENTICATION_OIDC_GROUPS_CLAIM: 'groups'
#
# AUTHORIZATION_RBAC_ENABLED: 'true'
# AUTHORIZATION_ADMIN_USERS: 'admin@example.test'
#
# *** BOTH TOGETHER IS THE USUAL PRODUCTION SHAPE: keys for
# *** services, OIDC for people. *** Service keys rotate by
# redeployment; human access rotates with the identity provider,
# which is where it belongs.
client = weaviate.connect_to_local(
auth_credentials=weaviate.classes.init.Auth.api_key("svc-search-key"))
# ==================================================================
# RBAC: more capable than a vector store needs to be, usefully.
# ==================================================================
# *** CHECK YOUR VERSION'S SUPPORT - IT HAS MOVED RECENTLY. ***
from weaviate.classes.rbac import Permissions
client.roles.create(
role_name="search_service",
permissions=[
Permissions.collections(collection="Product", read_config=True),
Permissions.data(collection="Product", read=True),
# NO create, NO update, NO delete. A search service searches.
],
)
client.roles.create(
role_name="ingest_service",
permissions=[
Permissions.collections(collection="Product", read_config=True),
Permissions.data(collection="Product", read=True, create=True,
update=True),
# NO DELETE. An ingest service that can delete is an ingest
# service that can delete everything.
],
)
client.roles.create(
role_name="reporting",
permissions=[Permissions.data(collection="Product", read=True)],
)
# *** A TENANT-SCOPED role - platform-enforced isolation: ***
client.roles.create(
role_name="tenant_acme_only",
permissions=[Permissions.data(collection="TenantProduct",
tenant="acme", read=True)],
)
client.roles.assign_to_user(user_id="search@svc", role_names=["search_service"])
print(client.roles.list_all())
# VERIFY THE DENIALS - every one must fail:
# search@svc deleting an object -> insufficient permissions
# search@svc creating a collection -> insufficient permissions
# ingest@svc deleting an object -> insufficient permissions
# report@svc any write -> insufficient permissions
# acme role querying tenant globex -> insufficient permissions
# any service client.backup.create(...) -> insufficient permissions
#
# *** WHERE RBAC IS UNAVAILABLE, THE HONEST POSITION IS THAT API KEYS
# *** MAP TO USERS WITH COARSE RIGHTS AND AUTHORISATION IS YOUR
# *** APPLICATION'S RESPONSIBILITY *** - and the design must STATE
# that rather than imply otherwise.
# ==================================================================
# TENANT ISOLATION: stronger here, and still write the one path.
# ==================================================================
def tenant_for(principal) -> str:
if not principal or not principal.tenant_id:
raise PermissionError("no tenant on the authenticated principal")
return principal.tenant_id
def search(principal, query: str, limit: int = 10):
coll = client.collections.get("TenantProduct")
return coll.with_tenant(tenant_for(principal)).query.hybrid(
query=query, alpha=0.6, limit=limit)
# *** AND NOTE THE FAILURE MODE IS BETTER THAN A NAMESPACE DESIGN: ***
#
# WRONG tenant from a request parameter -> THE WRONG DATA
# (as bad as Pinecone. Still write the one code path.)
#
# MISSING tenant -> *** AN ERROR: ***
# coll.query.hybrid(query="x")
# -> "collection TenantProduct has multi-tenancy enabled,
# but request was without tenant"
#
# In the Pinecone namespace design, OMITTING the namespace reads the
# DEFAULT namespace SILENTLY. Here it FAILS. Demonstrate both, and
# contrast them - it is a real argument for this design.
# ==================================================================
# TLS
# ==================================================================
# Terminate at Weaviate, or at a proxy in front of it. In a
# CLUSTER, the INTER-NODE traffic deserves encryption for the same
# reason as every other distributed database in this programme -
# it carries all your data between hosts.
# CLUSTER_DATA_BIND_PORT / CLUSTER_GOSSIP_BIND_PORT on a private
# network, and TLS on the HTTP and gRPC endpoints.
# ==================================================================
# MONITORING: a Prometheus endpoint, and the Weaviate-specific set.
# ==================================================================
# PROMETHEUS_MONITORING_ENABLED: 'true' -> :2112/metrics
#
# object_count{collection,shard}
# vector_index_size{collection,shard}
# *** vector_index_operations / VECTOR INDEX QUEUE LENGTH ***
# -> INDEXING IS FALLING BEHIND AN IMPORT. The
# Weaviate-specific metric that matters most during a load:
# objects are stored and NOT YET SEARCHABLE, which looks
# like missing data.
# queries_durations_ms{query_type} by type
# queries_filtered_vector_durations_ms the filter interaction
# batch_durations_ms / objects_durations_ms
# *** the VECTORISER's own latency *** - usually your bottleneck
# go_memstats_heap_inuse_bytes vs the container limit
# requests_total{status} error rate
# startup_durations_ms and index loading time
#
# AND, as the Pinecone course:
# *** A SCHEDULED RELEVANCE MEASUREMENT. It remains the only check
# *** that detects a degradation THE DATABASE WILL NEVER REPORT. ***
# Run the ground truth on a schedule and alert on a drop. An ef
# change, a quantiser change, a model update in a module image -
# all silently move recall, and nothing else tells you.
# ==================================================================
# *** SIZING COMES FROM THE MODULE 4 MEASUREMENTS. ***
# ==================================================================
# measured bytes/vector at our quantisation (SQ) = 1,200
# objects x 20,000,000
# -------------------------------------------------------------
# vectors = 24 GB
# x replication factor 3 = 72 GB
# + inverted index (BM25 + filterable) = ~14 GB
# + object store (properties) = ~22 GB
# + import headroom and query working set (~25%) = ~27 GB
# -------------------------------------------------------------
# PROVISION = ~135 GB
# -> 3 nodes x 64 GB, or 3 x 48 GB with BQ instead
#
# *** AN HNSW DEPLOYMENT IS SIZED BY MEMORY, AND THE QUANTISATION
# *** DECISION IS THEREFORE THE COST DECISION - WHICH IS WHY MODULE
# *** 4'S TABLE IS ALSO THE CAPACITY PLAN. ***
#
# with no quantisation: 3 x 160 GB nodes
# with SQ (0.95 recall): 3 x 64 GB nodes
# with BQ (0.91 recall): 3 x 48 GB nodes
# -> the recall/cost curve, in hardware. State the chosen point.
#
# SELF-HOSTED vs WEAVIATE CLOUD:
# self-hosted 3 x 64 GB instances $____/month
# + your operations time ____ hours/month
# Weaviate Cloud at this scale $____/month
# -> the honest comparison INCLUDES the operations time, and for
# most teams that is what decides it. Note also what you give
# up self-hosting: no managed upgrades, and the backup and
# restore procedure is yours to test.
Open this example in the editor and change it. Nothing you type is saved.
Discussion
No questions on this topic yet. Sign in to ask the first one.