Skip to content

Commit

Permalink
[SDK] Add studio user object
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 18, 2024
1 parent e0b4eb6 commit 82ee8a8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions libs/sdk-py/langgraph_sdk/auth/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,53 @@ def permissions(self) -> Sequence[str]:
...


class StudioUser:
"""A user object that's populated from authenticated requests from the LangGraph studio.
Note: Studio auth can be disabled in your `langgraph.json` config.
```json
{
"auth": {
"disable_studio_auth": true
}
}
```
You can use `isinstance` checks in your authorization handlers (`@auth.on`) to control access specifically
for developers accessing the instance from the LangGraph Studio UI.
???+ example "Examples"
```python
@auth.on
async def allow_developers(ctx: Auth.types.AuthContext, value: Any) -> None:
if isinstance(ctx.user, Auth.types.StudioUser):
return None
...
return False
```
"""

def __init__(self, username: str) -> None:
self.username = username

@property
def is_authenticated(self) -> bool:
return False

@property
def display_name(self) -> str:
return self.username

@property
def identity(self) -> str:
return self.username

@property
def permissions(self) -> Sequence[str]:
return ()


Authenticator = Callable[
...,
Awaitable[
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-sdk"
version = "0.1.47"
version = "0.1.48"
description = "SDK for interacting with LangGraph API"
authors = []
license = "MIT"
Expand Down

0 comments on commit 82ee8a8

Please sign in to comment.