Skip to content

Commit 92acd0c

Browse files
committed
Added 'allow_user_token' to security config to enable verification using the simpler 'user' token; allows this looser verification to be switched on or off per instrument
1 parent a868c97 commit 92acd0c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/murfey/server/api/auth.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ async def validate_instrument_token(
181181
decoded_data["session"], decoded_data["visit"]
182182
):
183183
raise JWTError
184-
# Check for Murfey TUI tokens (just a 'user' key)
185-
elif decoded_data.get("user") is not None:
186-
pass
184+
# Verify 'user' token if enabled
185+
elif security_config.allow_user_token:
186+
if not decoded_data.get("user"):
187+
raise JWTError
187188
else:
188189
raise JWTError
189190
except JWTError:

src/murfey/util/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,14 @@ class Security(BaseModel):
124124
ispyb_credentials: Optional[Path] = None
125125

126126
# Murfey server connection settings
127+
auth_url: str = ""
128+
auth_type: Literal["password", "cookie"] = "password"
127129
auth_algorithm: str = ""
128130
auth_key: str = ""
129-
auth_type: Literal["password", "cookie"] = "password"
130-
auth_url: str = ""
131-
instrument_auth_type: Literal["token", ""] = "token"
132-
instrument_auth_url: str = ""
133131
cookie_key: str = ""
132+
instrument_auth_url: str = ""
133+
instrument_auth_type: Literal["token", ""] = "token"
134+
allow_user_token: bool = False # TUI 'user' token support
134135
session_validation: str = ""
135136
session_token_timeout: Optional[int] = None
136137
allow_origins: list[str] = ["*"]

0 commit comments

Comments
 (0)