Skip to content

Commit

Permalink
fix: remove default issuer and add models docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Mar 6, 2025
1 parent b03406b commit f92d3f7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions diracx-core/src/diracx/core/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Models are used to define the data structure of the requests and responses
for the DiracX API. They are shared between the client components (cli, api) and
services components (db, logic, routers).
"""

from __future__ import annotations

from datetime import datetime
Expand Down
4 changes: 1 addition & 3 deletions diracx-core/src/diracx/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ class AuthSettings(ServiceSettingsBase):
# State key is used to encrypt/decrypt the state dict passed to the IAM
state_key: FernetKey

# TODO: this should probably be something mandatory
# to set by the user
token_issuer: str = "http://lhcbdirac.cern.ch/" # noqa: S105
token_issuer: str
token_key: TokenSigningKey
token_algorithm: str = "RS256" # noqa: S105
access_token_expire_minutes: int = 20
Expand Down
1 change: 0 additions & 1 deletion diracx-db/src/diracx/db/sql/sandbox_metadata/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class SandboxMetadataDB(BaseSQLDB):

async def get_owner_id(self, user: UserInfo) -> int | None:
"""Get the id of the owner from the database."""
# TODO: Follow https://github.com/DIRACGrid/diracx/issues/49
stmt = select(SBOwners.OwnerID).where(
SBOwners.Owner == user.preferred_username,
SBOwners.OwnerGroup == user.dirac_group,
Expand Down
5 changes: 1 addition & 4 deletions diracx-logic/src/diracx/logic/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ async def exchange_token(
"Dynamic registration of users is not yet implemented"
)

# Extract attributes from the settings and configuration
issuer = settings.token_issuer

# Check that the subject is part of the dirac users
if sub not in config.Registry[vo].Groups[dirac_group].Users:
raise PermissionError(
Expand Down Expand Up @@ -320,7 +317,7 @@ async def exchange_token(
access_payload: AccessTokenPayload = {
"sub": sub,
"vo": vo,
"iss": issuer,
"iss": settings.token_issuer,
"dirac_properties": list(properties),
"jti": str(uuid4()),
"preferred_username": preferred_username,
Expand Down
1 change: 1 addition & 0 deletions diracx-testing/src/diracx/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_auth_settings(
from diracx.core.settings import AuthSettings

yield AuthSettings(
token_issuer="http://lhcbdirac.cern.ch/",
token_algorithm="EdDSA",
token_key=private_key_pem,
state_key=fernet_key,
Expand Down
1 change: 1 addition & 0 deletions run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export DIRACX_OS_DB_JOBPARAMETERSDB='{"sqlalchemy_dsn": "sqlite+aiosqlite:///'${
export DIRACX_SERVICE_AUTH_TOKEN_KEY="file://${signing_key}"
export DIRACX_SERVICE_AUTH_STATE_KEY="${state_key}"
hostname_lower=$(hostname | tr -s '[:upper:]' '[:lower:]')
export DIRACX_SERVICE_AUTH_TOKEN_ISSUER="http://$hostname_lower:8000"
export DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS='["http://'"$hostname_lower"':8000/docs/oauth2-redirect"]'
export DIRACX_SANDBOX_STORE_BUCKET_NAME=sandboxes
export DIRACX_SANDBOX_STORE_AUTO_CREATE_BUCKET=true
Expand Down

0 comments on commit f92d3f7

Please sign in to comment.