Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] - Fetch user display name, initials and other details #225

Open
krassowski opened this issue Apr 10, 2024 · 0 comments
Open

[ENH] - Fetch user display name, initials and other details #225

krassowski opened this issue Apr 10, 2024 · 0 comments

Comments

@krassowski
Copy link
Member

Feature description

Nebari/jhub-apps are configured to use email address as username. The email address is taking up a lot of space and making the UI cumbersome to use in places like shared apps cards.

Value and/or benefit

Exposing a display name, name, and initials would allow for better user experience.

Anything else?

This will be three steps:

  1. Make JupyterHub support these details and return them in /user endpoint (if maintainers agree)
  2. Make Keycloak feed these details to JupyterHub
  3. Add extra fields to user model:
    class User(BaseModel):
    name: str
    admin: bool
    groups: Optional[List[str]]
    kind: str
    server: Optional[str] = None
    pending: Optional[str] = None
    last_activity: Optional[datetime] = None
    servers: Optional[Dict[str, Server]] = None
    scopes: List[str]
    auth_state: Optional[Dict] = None

I suspect nothing else will be needed on jhub-apps side since it just feeds the /user response to the model:

endpoint = "/user"
# normally we auth to Hub API with service api token,
# but this time auth as the user token to get user model
headers = {"Authorization": f"Bearer {token}"}
resp = await client.get(endpoint, headers=headers)
if resp.is_error:
raise HTTPException(
status.HTTP_401_UNAUTHORIZED,
detail={
"msg": "Error getting user info from token",
"request_url": str(resp.request.url),
"token": token,
"response_code": resp.status_code,
"hub_response": resp.json(),
},
)
user = User(**resp.json())
if any(scope in user.scopes for scope in access_scopes):
return user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant