jfjoch_broker: /start takes an optional `tokens` list (any number, all equivalent; writeOnly in the
API). While the current dataset has any, the endpoints that expose it - /statistics/data_collection,
/result/scan, /image_buffer/{start.cbor,image.cbor,image.jpeg,image.tiff}, /preview/plot{,.bin} -
answer 401 unless the request carries `Authorization: Bearer <token>`; /statistics keeps serving
the instrument view and only omits its `measurement` block. Enforcement is one pre-routing hook
over a named path set (the same set carries `bearerAuth` in jfjoch_api.yaml); tokens are compared
in constant time and never read back or logged. The tokens are replaced only by an accepted start,
and atomically with clearing the previous run's status, plots and image buffer, in this order:
clear, swap, import the new settings - so no moment serves the old run under the new tokens or the
new run's name under the old ones. Settings are validated on a copy first so a refused start
changes nothing.
jfjoch_viewer: a Token field (password echo) next to the http/https scheme in Open HTTP Connection,
JUNGFRAUJOCH_HTTP_TOKEN, and D-Bus LoadFile(..., token) / SetHttpToken; the dialog overrides the
others, nothing is persisted. A 401 clears the display, stops following and puts a line on the
status bar - no dialog, since a dataset changing hands is the normal cause.
Web frontend: key button in the top bar (token in sessionStorage, applied to the bearerAuth
operations by the generated client, and to the raw preview fetch), a tokens field in the start
form, and a "token required" hint on the plots. Python client: Configuration(access_token=...)
after regeneration.
Viewer: reference dataset accepts a structure-factor mmCIF (already read by content; the dialog
now offers it) and a model file can be chosen next to it (ProcessConfig::model_path, as
rugnux --model); the job also carries the reference's free-R flags, cell and setting, and the
copied command line states -z / --reference-column / --model. A grid scan keeps its own preferred
dataset-info plot and "Spots + background" means the spot count there. Dark theme: the navy hero
buttons, checked segments, warning texts and chart guide lines follow the theme instead of their
light-theme colours.
Docs: SECURITY.md section 3 is now the implemented scheme; a guided tour with four screenshots
in JFJOCH_VIEWER.md; broker, OpenAPI, Python client and frontend pages mention the token.
Tests: BearerTokens unit test and an HTTP round trip over the real broker HTTP layer (jfjoch_test
now compiles JFJochBrokerHttp.cpp and links httplib).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
83 lines
3.0 KiB
C++
83 lines
3.0 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <QActionGroup>
|
|
#include <QFont>
|
|
#include <QMenuBar>
|
|
|
|
#include "windows/JFJochHelperWindow.h"
|
|
|
|
class JFJochLicenseWindow;
|
|
class JFJochMouseShortcutsWindow;
|
|
class JFJochAcknowledgementWindow;
|
|
class QDockWidget;
|
|
|
|
class JFJochViewerMenu : public QMenuBar {
|
|
Q_OBJECT
|
|
QAction *toggleImageWindowAction = nullptr;
|
|
QAction *toggleMetadataWindowAction = nullptr;
|
|
QAction *toggleSpotWindowAction = nullptr;
|
|
QAction *toggleReflectionWindowAction = nullptr;
|
|
QAction *toggleProcessingWindowAction = nullptr;
|
|
QAction *toggleCalibrationWindowAction = nullptr;
|
|
|
|
QMenu *windowMenu = nullptr;
|
|
QActionGroup *fontZoomGroup = nullptr;
|
|
QFont baseFont; // the font the desktop handed us; the zoom is a multiple of it
|
|
int fontZoom = 100; // per cent: 100, 125 or 150
|
|
JFJochLicenseWindow *licenseWindow = nullptr;
|
|
JFJochMouseShortcutsWindow *mouseShortcutsWindow = nullptr;
|
|
JFJochAcknowledgementWindow *acknowledgementWindow = nullptr;
|
|
public:
|
|
explicit JFJochViewerMenu(QWidget *parent = nullptr);
|
|
~JFJochViewerMenu() override = default;
|
|
|
|
void AddWindowEntry(JFJochHelperWindow *window, const QString &name);
|
|
// Adds a dock's show/hide toggle to the Window menu (for docked panels).
|
|
void AddDockEntry(QDockWidget *dock, const QString &name);
|
|
// Back to 100 %, for "Reset all settings to defaults".
|
|
void ResetFontZoom();
|
|
// 100, 125 or 150 per cent; also reachable from the display toolbar's size buttons.
|
|
void SetFontZoom(int percent);
|
|
[[nodiscard]] int FontZoom() const { return fontZoom; }
|
|
|
|
public slots:
|
|
void openSelected(); // also reachable from the toolbar's open-dataset button
|
|
void openHttpSelected(); // also reachable from the toolbar's HTTP-sync button
|
|
void setHttpToken(const QString &token); // pre-fills the token field of the HTTP dialog
|
|
|
|
signals:
|
|
void fileOpenSelected(const QString &filename, qint64 image_number, qint64 summation, bool retry);
|
|
void httpTokenSelected(const QString &token); // emitted before fileOpenSelected for an HTTP URL
|
|
void fileCloseSelected();
|
|
|
|
void saveUserMaskTiffSelected(const QString &filename);
|
|
void loadUserMaskTiffSelected(const QString &filename, bool replace);
|
|
void uploadUserMaskSelected();
|
|
void clearUserMaskSelected();
|
|
void openDatasetInfo();
|
|
|
|
void imageLayoutSelected();
|
|
void processingLayoutSelected();
|
|
void resetLayoutSelected();
|
|
void resetSettingsSelected();
|
|
void fontZoomChanged(int percent);
|
|
|
|
private slots:
|
|
void aboutSelected();
|
|
void licensesSelected();
|
|
void mouseShortcutsSelected();
|
|
void acknowledgementsSelected();
|
|
void quitSelected();
|
|
void closeSelected();
|
|
|
|
void saveUserMaskAsTiffSelected();
|
|
void uploadUserMaskAction();
|
|
|
|
private:
|
|
QString http_token;
|
|
void openLoadUserMaskTiff(bool replace);
|
|
};
|