Allow reading the log via REST without superuser authorization - #769
Merged
Conversation
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.
Member
|
Nice PR, thank you. |
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /ws/rest/logand/log/sizeare already gated by the fine-grainedrest-3#getLogandrest-3#getLogSizeauthorizations, but the underlying model operations (ModelDiagnosticService.getLogFileContent()/getLogFileSize()) callsecurityEnforcer.authorizeAll(), i.e. they requireauthorization-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 aauthorization-model-3#readLogaction and uses it inModelDiagControllerinstead ofauthorizeAll(), following the existing#readThreadsprecedent. One action covers both content and size, as#readThreadsdoes for its three endpoints. The change is backward compatible (#allapplies to any action) and strictly opt-in — nothing built-in grants#readLog. The otherauthorizeAll()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.TestRestServiceXmlandTestRestServiceJsonpass 74/74 each. Backports tosupport-4.10,support-4.9andsupport-4.8are ready as clean cherry-picks — happy to open them once this is accepted.