Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/murfey/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,20 @@
rich_handler.setLevel(logging.DEBUG if args.debug else logging.INFO)

# Set up websocket app and handler
client_id = requests.get(
client_id_response = requests.get(

Check warning on line 278 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L278

Added line #L278 was not covered by tests
f"{murfey_url.geturl()}{url_path_for('session_control.router', 'new_client_id')}"
).json()
)
if client_id_response.status_code == 401:
exit(

Check warning on line 282 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L282

Added line #L282 was not covered by tests
"This instrument is not authorised to run the TUI app; please use the "
"Murfey web UI instead"
)
elif client_id_response.status_code != 200:
exit(

Check warning on line 287 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L287

Added line #L287 was not covered by tests
"Unable to establish connection to Murfey server: \n"
f"{client_id_response.json()}"
)
client_id: dict = client_id_response.json()

Check warning on line 291 in src/murfey/client/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/__init__.py#L291

Added line #L291 was not covered by tests
ws = murfey.client.websocket.WSApp(
server=args.server,
id=client_id["new_id"],
Expand Down
1 change: 1 addition & 0 deletions src/murfey/instrument_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import murfey
import murfey.client.update
import murfey.client.websocket
from murfey.client.customlogging import CustomHandler
from murfey.util import LogFilter
from murfey.util.client import read_config
Expand Down
6 changes: 5 additions & 1 deletion src/murfey/server/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,16 @@
if expiry_time := decoded_data.get("expiry_time"):
if expiry_time < time.time():
raise JWTError
# Check that the decoded session corresponds to the visit
elif decoded_data.get("session") is not None:
# Check that the decoded session corresponds to the visit
if not validate_session_against_visit(
decoded_data["session"], decoded_data["visit"]
):
raise JWTError
# Verify 'user' token if enabled
elif security_config.allow_user_token:
if not decoded_data.get("user"):
raise JWTError

Check warning on line 187 in src/murfey/server/api/auth.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/auth.py#L187

Added line #L187 was not covered by tests
else:
raise JWTError
except JWTError:
Expand Down
9 changes: 5 additions & 4 deletions src/murfey/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ class Security(BaseModel):
ispyb_credentials: Optional[Path] = None

# Murfey server connection settings
auth_url: str = ""
auth_type: Literal["password", "cookie"] = "password"
auth_algorithm: str = ""
auth_key: str = ""
auth_type: Literal["password", "cookie"] = "password"
auth_url: str = ""
instrument_auth_type: Literal["token", ""] = "token"
instrument_auth_url: str = ""
cookie_key: str = ""
instrument_auth_url: str = ""
instrument_auth_type: Literal["token", ""] = "token"
allow_user_token: bool = False # TUI 'user' token support
session_validation: str = ""
session_token_timeout: Optional[int] = None
allow_origins: list[str] = ["*"]
Expand Down