Skip to content

Commit

Permalink
add jhub-apps authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Dec 13, 2024
1 parent d29fbd4 commit 3eab4fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ragna/deploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
"DummyBasicAuth",
"GithubOAuth",
"InMemoryKeyValueStore",
"JhubAppsAuth",
"JupyterhubServerProxyAuth",
"KeyValueStore",
"NoAuth",
"RedisKeyValueStore",
]

from ._auth import Auth, DummyBasicAuth, GithubOAuth, JupyterhubServerProxyAuth, NoAuth
from ._auth import (
Auth,
DummyBasicAuth,
GithubOAuth,
JhubAppsAuth,
JupyterhubServerProxyAuth,
NoAuth,
)
from ._config import Config
from ._key_value_store import InMemoryKeyValueStore, KeyValueStore, RedisKeyValueStore

Expand Down
14 changes: 14 additions & 0 deletions ragna/deploy/_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,17 @@ def __init__(self) -> None:

def login(self, request: Request) -> schemas.User:
return self._user


class JhubAppsAuth(_AutomaticLoginAuthBase):
async def login(self, request: Request) -> schemas.User:
assert "jhub_apps_access_token" in request.cookies
async with httpx.AsyncClient(
base_url=f"https://{request.url.netloc}",
cookies=request.cookies,
) as client:
response = await client.get("/services/japps/user")
assert response.is_success

user_data = response.json()
return schemas.User(name=user_data.pop("name"), data=user_data)

0 comments on commit 3eab4fc

Please sign in to comment.