Skip to content

Commit

Permalink
Add PlankaAuthClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Andrieu committed Jan 12, 2025
1 parent 535e18f commit f650310
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/utils/auth/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,38 @@ def get_userinfo(cls, user: models_core.CoreUser):
"email": user.email,
"is_admin": is_user_member_of_an_allowed_group(user, [GroupType.admin]),
}


class PlankaAuthClient(BaseAuthClient):
"""
An auth client for Planka, a Trello alternative for kanban boards
Docs for OIDC integration:
https://docs.planka.cloud/docs/Configuration/OIDC/
"""

allow_pkce_with_client_secret: bool = True # required to exchange OIDC code
allowed_scopes: set[ScopeType | str] = {
ScopeType.openid,
ScopeType.profile,
}

@classmethod
def get_userinfo(cls, user: models_core.CoreUser):
# Must match ^[a-zA-Z0-9]+((_|\.)?[a-zA-Z0-9])*$
username = unidecode.unidecode(
f"{user.firstname.strip()}.{user.name.strip()}",
).replace(" ", "_")
username = re.sub(r"[^a-zA-Z0-9._]", "", username)

return {
"sub": user.id,
"name": get_display_name(
firstname=user.firstname,
name=user.name,
nickname=user.nickname,
),
"preferred_username": username,
"groups": [group.name for group in user.groups] + [user.account_type.value],
"email": user.email,
}

0 comments on commit f650310

Please sign in to comment.