Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
74032e1
Ability to configure different auth routes for instrument server and …
d-j-hatton May 29, 2025
c281170
Split token auth mechanisms for two different groups of endpoints
d-j-hatton May 29, 2025
606a957
Resolved merge conflicts with 'main' branch
tieneupin Jun 2, 2025
27a681a
Major refactor of 'murfey.server.api.auth', rearranging functions by …
tieneupin Jun 3, 2025
d5efb6f
Added documentation to instrument server-side token validation function
tieneupin Jun 3, 2025
02e8c19
Refactored 'murfey.server.api.file_manip' into 'file_io_instrument', …
tieneupin Jun 3, 2025
f7b4006
Added prefixes to the 'auth' and 'clem' routers
tieneupin Jun 3, 2025
2a8e75e
Updated route manifest with new URL paths
tieneupin Jun 4, 2025
c5956e8
Moved 'count_number_of_omves()' from 'session_info' router to 'sessio…
tieneupin Jun 4, 2025
5f66b8b
Fixed broken test; used 'url_path_for()' instead of hard-coding URL now
tieneupin Jun 5, 2025
7a9d83d
Attempt to fix broken test
tieneupin Jun 5, 2025
e8f57e4
Token generating URL was outdated; replaced with URL constructor; rep…
tieneupin Jun 5, 2025
96fce0c
Used FastAPI's 'APIKeyCookie' object for cookie authentication instea…
tieneupin Jun 5, 2025
fb19d6c
Typo in router name
tieneupin Jun 5, 2025
ceebff5
Adjusted logic in 'password' block of 'generate_token()' to avoid uni…
tieneupin Jun 5, 2025
0bfeafa
Added mock database to 'test_movie_count()', use 'mint_session_token(…
tieneupin Jun 5, 2025
3076af2
Rewrote 'test_movie_count' function to make use database set up in py…
tieneupin Jun 5, 2025
27748f0
Use Murfey database fixture and add entries to it
tieneupin Jun 5, 2025
89a0607
No need to re-do Session table entry
tieneupin Jun 5, 2025
00fe67f
Put the database and validation overrides in a test FastAPI client fi…
tieneupin Jun 5, 2025
7fae5d8
Database session gets reset every test, so the FastAPI test client th…
tieneupin Jun 5, 2025
2269269
Moved Murfey DB URL out of fixture and into a module-level variable
tieneupin Jun 5, 2025
e6c0f3c
Import 'murfey_db' only after mocks have been set
tieneupin Jun 5, 2025
c35cc74
Removed patch decorators from fixtures due to decorator conflict
tieneupin Jun 5, 2025
8cb679a
Move test_client startup into test function, as database state doesn'…
tieneupin Jun 5, 2025
de4a73a
Test funciton directly (ノಠ益ಠ)ノ彡┻━┻
tieneupin Jun 5, 2025
ff03dcb
Merge branch 'main' into auth-procedures
tieneupin Jun 5, 2025
1cdae65
Minor fixes to comments and redundant variables
tieneupin Jun 5, 2025
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
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ GitHub = "https://github.com/DiamondLightSource/python-murfey"
"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run"
"murfey.spa_ispyb_entries" = "murfey.cli.spa_ispyb_messages:run"
"murfey.transfer" = "murfey.cli.transfer:run"
[project.entry-points."murfey.auth.token_validation"]
"password" = "murfey.server.api.auth:password_token_validation"
[project.entry-points."murfey.config.extraction"]
"murfey_machine" = "murfey.util.config:get_extended_machine_config"
[project.entry-points."murfey.workflows"]
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/client/contexts/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def post_transfer(
)
if not environment.movie_counters.get(str(source)):
movie_counts_get = capture_get(
f"{environment.url.geturl()}{url_path_for('session_info.router', 'count_number_of_movies')}",
f"{environment.url.geturl()}{url_path_for('session_control.router', 'count_number_of_movies')}",
)
if movie_counts_get is not None:
environment.movie_counters[str(source)] = count(
Expand All @@ -581,7 +581,7 @@ def post_transfer(
eer_fractionation_file = None
if file_transferred_to.suffix == ".eer":
response = capture_post(
f"{str(environment.url.geturl())}{url_path_for('file_manip.router', 'write_eer_fractionation_file', visit_name=environment.visit, session_id=environment.murfey_session)}",
f"{str(environment.url.geturl())}{url_path_for('file_io_instrument.router', 'write_eer_fractionation_file', visit_name=environment.visit, session_id=environment.murfey_session)}",
json={
"eer_path": str(file_transferred_to),
"fractionation": environment.data_collection_parameters[
Expand Down
2 changes: 1 addition & 1 deletion src/murfey/client/contexts/tomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _add_tilt(
eer_fractionation_file = None
if environment.data_collection_parameters.get("num_eer_frames"):
response = requests.post(
f"{str(environment.url.geturl())}{url_path_for('file_manip.router', 'write_eer_fractionation_file', visit_name=environment.visit, session_id=environment.murfey_session)}",
f"{str(environment.url.geturl())}{url_path_for('file_io_instrument.router', 'write_eer_fractionation_file', visit_name=environment.visit, session_id=environment.murfey_session)}",
json={
"num_frames": environment.data_collection_parameters[
"num_eer_frames"
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/client/multigrid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
log.info(f"starting rsyncer: {source}")
if transfer:
# Always make sure the destination directory exists
make_directory_url = f"{self.murfey_url}{url_path_for('file_manip.router', 'make_rsyncer_destination', session_id=self.session_id)}"
make_directory_url = f"{self.murfey_url}{url_path_for('file_io_instrument.router', 'make_rsyncer_destination', session_id=self.session_id)}"

Check warning on line 254 in src/murfey/client/multigrid_control.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/multigrid_control.py#L254

Added line #L254 was not covered by tests
capture_post(make_directory_url, json={"destination": destination})
if self._environment:
self._environment.default_destinations[source] = destination
Expand Down Expand Up @@ -437,7 +437,7 @@
log.info("Registering tomography processing parameters")
if self._environment.data_collection_parameters.get("num_eer_frames"):
eer_response = requests.post(
f"{str(self._environment.url.geturl())}{url_path_for('file_manip.router', 'write_eer_fractionation_file', visit_name=self._environment.visit, session_id=self._environment.murfey_session)}",
f"{str(self._environment.url.geturl())}{url_path_for('file_io_instrument.router', 'write_eer_fractionation_file', visit_name=self._environment.visit, session_id=self._environment.murfey_session)}",
json={
"num_frames": self._environment.data_collection_parameters[
"num_eer_frames"
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/client/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
log.info(f"starting rsyncer: {source}")
if transfer:
# Always make sure the destination directory exists
make_directory_url = f"{str(self._url.geturl())}{url_path_for('file_manip.router', 'make_rsyncer_destination', session_id=self._environment.murfey_session)}"
make_directory_url = f"{str(self._url.geturl())}{url_path_for('file_io_instrument.router', 'make_rsyncer_destination', session_id=self._environment.murfey_session)}"

Check warning on line 212 in src/murfey/client/tui/app.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/tui/app.py#L212

Added line #L212 was not covered by tests
capture_post(make_directory_url, json={"destination": destination})
if self._environment:
self._environment.default_destinations[source] = destination
Expand Down Expand Up @@ -488,7 +488,7 @@
log.info("Registering tomography processing parameters")
if self.app._environment.data_collection_parameters.get("num_eer_frames"):
eer_response = requests.post(
f"{str(self.app._environment.url.geturl())}{url_path_for('file_manip.router', 'write_eer_fractionation_file', visit_name=self.app._environment.visit, session_id=self.app._environment.murfey_session)}",
f"{str(self.app._environment.url.geturl())}{url_path_for('file_io_instrument.router', 'write_eer_fractionation_file', visit_name=self.app._environment.visit, session_id=self.app._environment.murfey_session)}",
json={
"num_frames": self.app._environment.data_collection_parameters[
"num_eer_frames"
Expand Down
4 changes: 2 additions & 2 deletions src/murfey/client/tui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def determine_default_destination(
_default = environment.destination_registry[source_name]
else:
suggested_path_response = capture_post(
url=f"{str(environment.url.geturl())}{url_path_for('file_manip.router', 'suggest_path', visit_name=visit, session_id=environment.murfey_session)}",
url=f"{str(environment.url.geturl())}{url_path_for('file_io_instrument.router', 'suggest_path', visit_name=visit, session_id=environment.murfey_session)}",
json={
"base_path": f"{destination}/{visit}/{mid_path.parent if include_mid_path else ''}/raw",
"touch": touch,
Expand Down Expand Up @@ -906,7 +906,7 @@ def on_button_pressed(self, event):
f"Gain reference file {posix_path(self._dir_tree._gain_reference)!r} was not successfully transferred to {visit_path}/processing"
)
process_gain_response = requests.post(
url=f"{str(self.app._environment.url.geturl())}{url_path_for('file_manip.router', 'process_gain', session_id=self.app._environment.murfey_session)}",
url=f"{str(self.app._environment.url.geturl())}{url_path_for('file_io_instrument.router', 'process_gain', session_id=self.app._environment.murfey_session)}",
json={
"gain_ref": str(self._dir_tree._gain_reference),
"eer": bool(
Expand Down
5 changes: 4 additions & 1 deletion src/murfey/instrument_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
def validate_session_token(
session_id: int, token: Annotated[str, Depends(oauth2_scheme)]
):
"""
Validates the token received from the backend server
"""
try:
decoded_data = jwt.decode(
token,
Expand All @@ -62,7 +65,7 @@ def validate_session_token(
except JWTError:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
detail="Could not validate credentials from backend",
headers={"WWW-Authenticate": "Bearer"},
)
return session_id
Expand Down
Loading