Skip to content

Commit

Permalink
Fix use of sub instead of prefered_name
Browse files Browse the repository at this point in the history
  • Loading branch information
natthan-pigoux authored and chrisburr committed Oct 15, 2024
1 parent 107f387 commit 2b410da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion diracx-routers/src/diracx/routers/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ async def exchange_token(
f"User is not a member of the requested group ({preferred_username}, {dirac_group})"
)

allowed_user_properties = get_allowed_user_properties(config, user_info, vo)
allowed_user_properties = get_allowed_user_properties(config, sub, vo)
if not set(properties).issubset(allowed_user_properties):
raise ValueError(
f"{set(properties) - allowed_user_properties} are not valid properties for user {preferred_username}, "
Expand Down
7 changes: 2 additions & 5 deletions diracx-routers/src/diracx/routers/utils/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pydantic import BaseModel, Field
from pydantic_settings import SettingsConfigDict

from diracx.core.config.schema import UserConfig
from diracx.core.models import UserInfo
from diracx.core.properties import SecurityProperty
from diracx.core.settings import FernetKey, ServiceSettingsBase, TokenSigningKey
Expand Down Expand Up @@ -120,12 +119,10 @@ async def verify_dirac_access_token(
)


def get_allowed_user_properties(
config: Config, user_info: UserConfig, vo: str
) -> set[SecurityProperty]:
def get_allowed_user_properties(config: Config, sub, vo: str) -> set[SecurityProperty]:
"""Retrieve all properties of groups a user is registered in."""
allowed_user_properties = set()
for group in config.Registry[vo].Groups:
if user_info.PreferedUsername in config.Registry[vo].Groups[group].Users:
if sub in config.Registry[vo].Groups[group].Users:
allowed_user_properties.update(config.Registry[vo].Groups[group].Properties)
return allowed_user_properties

0 comments on commit 2b410da

Please sign in to comment.