langchain-ai / opengpts

MIT License
6.31k stars 829 forks source link

Introduce auth #287

Closed bakar-io closed 2 months ago

bakar-io commented 2 months ago

Introduces auth into OpenGPTs as the first step, before integrating permissions.

Allows users to get started with the project quickly after cloning the repo (via NOOPAuth auth handler), as well as enabling production use-cases via JWTAuthLocal and JWTAuthOIDC.

auth.md documents the usage of JWT auth in detail.

bakar-io commented 2 months ago

@andrewnguonly Fundamentally, handler takes a request and returns a User:

class AuthHandler(ABC):
    @abstractmethod
    async def __call__(self, request: Request) -> User:
        """Auth handler that returns a user object or raises an HTTPException."""

So, we are not limited by JWT auth. We're free to implement any auth mechanism in the future.