@@ -712,3 +712,73 @@ await collection.delete({
712712
713713
714714` .delete ` also supports the ` where ` filter. If no ` ids ` are supplied, it will delete all items in the collection that match the ` where ` filter.
715+
716+
717+ ## Authentication
718+
719+ You can configure Chroma to use authentication when in server/client mode only.
720+
721+ Supported authentication methods:
722+
723+ | Authentication Method | Basic Auth (Pre-emptive) |
724+ | -----------------------| ---------------------------------------------------------------------------------------------------------------------------|
725+ | Description | [ RFC 7617] ( https://www.rfc-editor.org/rfc/rfc7617 ) Basic Auth with ` user:password ` base64-encoded ` Authorization ` header. |
726+ | Status | ` Alpha ` |
727+ | Server-Side Support | ✅ ` Alpha ` |
728+ | Client/Python | ✅ |
729+ | Client/JS | ➖ |
730+
731+ ### Basic Authentication
732+
733+ <Tabs queryString groupId =" lang " className =" hideTabSwitcher " >
734+ <TabItem value =" py " label =" Python " >
735+
736+ #### Server Setup
737+
738+ ##### Generate Server-Side Credentials
739+
740+ :::note Security Practices
741+ A good security practice is to store the password securely. In the example below we use bcrypt (currently the only supported hash in Chroma server side auth) to hash the plaintext password.
742+ :::
743+
744+ ``` bash
745+ docker run --rm --entrypoint htpasswd httpd:2 -Bbn admin admin > server.htpasswd
746+ ```
747+
748+ ##### Running the Server
749+
750+ Create a ` .chroma_env ` file with the following contents:
751+
752+ ``` ini title=".chroma_env"
753+ CHROMA_SERVER_AUTH_CREDENTIALS_FILE =" /chroma/server.htpasswd"
754+ CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER =' chromadb.auth.providers.HtpasswdFileServerAuthCredentialsProvider'
755+ CHROMA_SERVER_AUTH_PROVIDER =' chromadb.auth.basic.BasicAuthServerProvider'
756+ ```
757+
758+ ``` bash
759+ docker-compose --env-file ./.chroma_env up -d --build
760+ ```
761+
762+ #### Client Setup
763+
764+ ``` python
765+ import chromadb
766+ from chromadb.config import Settings
767+
768+ client = chromadb.HttpClient(
769+ settings = Settings(chroma_client_auth_provider = " chromadb.auth.basic.BasicAuthClientProvider" ,chroma_client_auth_credentials = " admin:admin" ))
770+ client.heartbeat() # this should work with or without authentication - it is a public endpoint
771+
772+ client.get_version() # this should work with or without authentication - it is a public endpoint
773+
774+ client.list_collections() # this is a protected endpoint and requires authentication
775+ ```
776+
777+ </TabItem >
778+ <TabItem value =" js " label =" JavaScript " >
779+
780+ :::info Not Available
781+ Authentication is not yet supported in JS
782+ :::
783+ </TabItem >
784+ </Tabs >
0 commit comments