Skip to content

Allow reading the log via REST without superuser authorization - #769

Merged
mederly merged 1 commit into
Evolveum:masterfrom
martin-lizner:read-log-authorization
Aug 18, 2026
Merged

Allow reading the log via REST without superuser authorization#769
mederly merged 1 commit into
Evolveum:masterfrom
martin-lizner:read-log-authorization

Conversation

@martin-lizner

Copy link
Copy Markdown
Contributor

GET /ws/rest/log and /log/size are already gated by the fine-grained rest-3#getLog and rest-3#getLogSize authorizations, but the underlying model operations (ModelDiagnosticService.getLogFileContent() / getLogFileSize()) call securityEnforcer.authorizeAll(), i.e. they require authorization-3#all. So in practice only a superuser can read the log, and a read-only administrator cannot be granted log access at all. This adds a authorization-model-3#readLog action and uses it in ModelDiagController instead of authorizeAll(), following the existing #readThreads precedent. One action covers both content and size, as #readThreads does for its three endpoints. The change is backward compatible (#all applies to any action) and strictly opt-in — nothing built-in grants #readLog. The other authorizeAll() sites in that class are deliberately left alone.

Also adds five tests for the two endpoints, which had none: 403 without #readLog, 200 with it as a non-superuser, and 200 as superuser. TestRestServiceXml and TestRestServiceJson pass 74/74 each. Backports to support-4.10, support-4.9 and support-4.8 are ready as clean cherry-picks — happy to open them once this is accepted.

The REST endpoints GET /ws/rest/log and GET /ws/rest/log/size are already
guarded by fine-grained REST authorizations (authorization-rest-3#getLog
and #getLogSize). However, the underlying model operations
ModelDiagnosticService.getLogFileContent() and getLogFileSize() called
securityEnforcer.authorizeAll(), i.e. they required authorization-3#all.
The effect was that only a superuser could read the log, and the
fine-grained REST authorizations were unusable in practice: a read-only
administrator could not be granted access to the log at all.

This adds a new model authorization action

    http://midpoint.evolveum.com/xml/ns/public/security/authorization-model-3#readLog

and uses it in ModelDiagController instead of authorizeAll(). This follows
the existing #readThreads pattern used for the thread dump operations, and
the note in ExtensionSchemaRestController about combining a specific REST
action with a specific model action instead of "all".

A single model action covers both the content and the size operations: the
size is strictly less information than the content, and clients are
expected to use them together (see the ReturnedDataPosition /
CurrentLogFileSize response headers). Deployments that want to expose only
one of the two endpoints can still do so via the REST-level authorizations.

The change is backward compatible: #all is applicable to any action, so
existing superusers are unaffected.

Also adds REST integration tests for both endpoints - they had no test
coverage at all - and documents the required authorization on the service
interface.

The other authorizeAll() call sites in ModelDiagController (memory
information, repository diagnostics, etc.) are deliberately left unchanged.
@mederly
mederly merged commit 6ba5e74 into Evolveum:master Aug 18, 2026
@mederly

mederly commented Aug 18, 2026

Copy link
Copy Markdown
Member

Nice PR, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants