Skip to content

alinafematenda/langgraph-agentic-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python RAG Agent using LangGraph and Auth0 FGA

This example demonstrates how to combine LangChain with robust authorization controls for RAG workflows. Using Auth0 FGA, it ensures that users can only access documents they are authorized to view. The example retrieves relevant documents, enforces access permissions, and generates responses based only on authorized data, maintaining strict data security and preventing unauthorized access.

Getting Started

Prerequisites

  • An Auth0 FGA account, you can create one here.
  • An OpenAI account and API key create one here.

Setup

  1. Create a .env file using the format below:

     # OpenAI
     OPENAI_API_KEY=xx-xxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxx
    
     # Auth0 FGA
     FGA_STORE_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxx
     FGA_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxx
     FGA_CLIENT_SECRET=xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxx
     # Required only for non-US regions
     FGA_API_URL=https://api.xxx.fga.dev
     FGA_API_AUDIENCE=https://api.xxx.fga.dev/

Obtain OpenAI API Key

Use this page for instructions on how to find your OpenAI API key. Once you have your key, update the .env file accordingly.

Configure Auth0 FGA

  1. Create a client

    Navigate to Settings and in the Authorized Clients section click + Create Client button. On the new page give your client a name and mark all three client permissions then click Create.

  2. Copy the information on the modal and update your .env file with the values you now have for FGA_STORE_ID, FGA_CLIENT_ID, and FGA_CLIENT_SECRET. Click Continue to get values for FGA_API_URL and FGA_API_AUDIENCE.

How to run it

  1. Install dependencies using Poetry.

    $ python -m venv venv
    $ source venv/bin/activate
    $ pip install -r requirements.txt
  2. Initialize the FGA model and tuples

    $ python ./scripts/fga_init.py
  3. Running the example

    python main.py

Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the Apache 2.0 license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages