Skip to content

feat(log): add opt-in session ID logging - #53506

Open
ChristophWurst wants to merge 1 commit into
masterfrom
feat/log/log-session-id
Open

ChristophWurst wants to merge 1 commit into
masterfrom
feat/log/log-session-id

Conversation

@ChristophWurst

@ChristophWurst ChristophWurst commented Jun 16, 2025 •

Copy link
Copy Markdown
Member

Summary

Optionally allow admins to enable logging of session IDs. This allows to see when a new session is started for a user. That information is not trackable right now.

TODO

  • Do

Checklist

@ChristophWurst ChristophWurst self-assigned this Jun 16, 2025
@ChristophWurst
ChristophWurst requested a review from a team as a code owner June 16, 2025 09:16
@ChristophWurst ChristophWurst added the 3. to review Waiting for reviews label Jun 16, 2025
@ChristophWurst
ChristophWurst requested review from Altahrim, artonge and provokateurin and removed request for a team June 16, 2025 09:16
@ChristophWurst

Copy link
Copy Markdown
Member Author

/backport to stable31

@ChristophWurst

Copy link
Copy Markdown
Member Author

/backport to stable30

Comment thread lib/private/Log.php Outdated
}
if ($this->config->getValue('log.sessionId', false)) {
try {
$entry['sessionId'] = \OCP\Server::get(ISession::class)->getId();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No DI possible here?

@joshtrichards joshtrichards Jun 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it can be done safely nor is worth the risk at the moment. Since Log is a core service and this path is opt-in, lookup seems lower risk than DI here. Doing the session ID lookup in a protected helper method might be a good idea though for testability.

Comment thread config/config.sample.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is that this logs the raw session ID, which is fairly sensitive. Could we either:

  1. document very explicitly that log.sessionId is for temporary debugging only and logs sensitive identifiers, or

  2. log a derived value instead (e.g. hashed session ID) if correlation is all we need?

Comment thread config/config.sample.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'debug.sessionId' => false,

Maybe to make debugging purposes only even more explicit. ;)

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Assisted-by: ClaudeCode:claude-opus-5-5

@susnux susnux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased but this needs adjustment to follow naming policies!

Comment thread config/config.sample.php
*
* Defaults to ``false``.
*/
'log.sessionId' => false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/configuration.html#naming-conventions

Suggested change
'log.sessionId' => false,
'log_debug_sessionId' => false,

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants