From 3dd1e679772f513bb5c4e36d4b087ea5ddc85977 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:49:18 -0800 Subject: [PATCH] Add mermaid --- docs/docs/tutorials/auth/getting_started.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/docs/tutorials/auth/getting_started.md b/docs/docs/tutorials/auth/getting_started.md index 1871a9b08..7546a5f74 100644 --- a/docs/docs/tutorials/auth/getting_started.md +++ b/docs/docs/tutorials/auth/getting_started.md @@ -1,6 +1,6 @@ # Setting up custom authentication -Let's learn how to add custom authentication to a LangGraph Platformdeployment. We'll cover the core concepts of token-based authentication and show how to integrate with an authentication server. +Let's learn how to add custom authentication to a LangGraph Platform deployment. We'll cover the core concepts of token-based authentication and show how to integrate with an authentication server. ??? note "Default authentication" When deploying to LangGraph Cloud, requests are authenticated using LangSmith API keys by default. This gates access to the server but doesn't provide fine-grained access control over threads. Self-hosted LangGraph platform has no default authentication. This guide shows how to add custom authentication handlers that work in both cases, to provide fine-grained access control over threads, runs, and other resources. @@ -15,6 +15,21 @@ The key components in a token-based authentication system are: After implementing the following steps, when a user's client application (such as their web browser or mobile app) wants to access resources in LangGraph, the following steps occur: +```mermaid +sequenceDiagram + participant User + participant AuthServer as Auth Server + participant LangGraph + + User->>AuthServer: 1. Authenticate (username/password) + AuthServer-->>User: 2. Return signed JWT token + User->>LangGraph: 3. Request with JWT in header + LangGraph->>AuthServer: 4a. Validate token + AuthServer-->>LangGraph: 4b. Confirm token validity + Note over LangGraph: 4c. Apply access filters + LangGraph-->>User: Return authorized resources +``` + 1. User authenticates with the auth server (username/password, OAuth, "Sign in with Google", etc.) 2. Auth server returns a signed JWT token attesting "I am user X with claims/roles Y" 3. User includes this token in request headers to LangGraph @@ -309,6 +324,7 @@ This handler matches ALL requests to threads, runs, assistants, crons, and other ## Deploying to LangGraph Cloud Now that you've set everything up, you can deploy your LangGraph application to LangGraph Cloud! Simply: + 1. Push your code to a new github repository. 2. Navigate to the LangGraph Platform page and click "+New Deployment". 3. Connect to your GitHub repository and copy the contents of your `.env` file as environment variables.