This is fully open, so lets add some access control. We'll go with
access token method, which is super simple. Add this to the fly.toml
file.
1
2
3
| [env]
CHROMA_SERVER_AUTHN_CREDENTIALS="test-token"
CHROMA_SERVER_AUTHN_PROVIDER="chromadb.auth.token_authn.TokenAuthenticationServerProvider"
|
And
Try it again:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| // with-auth-test.js
import { ChromaClient } from "chromadb";
const client = new ChromaClient({
path: "https://chromadb-on-fly-io.fly.dev",
auth: {provider: "token", credentials: "test-token"}
});
const collection = await client.getOrCreateCollection({
name: "my_authed_collection",
metadata: {
description: "My second collection"
}
});
const collections = await client.listCollections();
console.log( "collections", collections );
|
collections [
{
name: 'my_collection',
id: '95d68c89-5ee6-42f2-9421-8cb57b8f9aeb',
metadata: { description: 'My first collection' },
tenant: 'default_tenant',
database: 'default_database'
},
{
name: 'my_authed_collection',
id: '98930e2d-5f72-4a6f-a185-bbe4d606f040',
metadata: { description: 'My second collection' },
tenant: 'default_tenant',
database: 'default_database'
}
]