dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[Improvement-17933][api] Restrict audit logs to current user for non-admin users

Open qiuyanjun888 opened this issue 5 months ago • 1 comments

Was this PR generated or assisted by AI?

YES. The patch and tests were assisted by AI and reviewed locally.

Purpose of the pull request

Fix #17933. Restrict global audit log queries so non-admin users can only view their own audit logs, while administrators keep the full audit view.

Brief change log

  • Pass login user context from AuditLogController to AuditService.
  • Add an optional userId filter to AuditLogMapper.queryAuditLog.
  • Apply userId filtering for non-admin users and keep admin queries global.
  • Add/adjust unit tests for service behavior and mapper userId filtering.

Verify this pull request

This change added tests and can be verified as follows:

  • ./mvnw verify -B -pl "dolphinscheduler-dao,dolphinscheduler-api" -Dmaven.test.skip=false -Dspotless.skip=true -DskipUT=false -Danalyze.skip=true -Djacoco.skip=true -Dsurefire.printSummary=true -Dsurefire.useFile=false -Dsurefire.reportFormat=plain -Dsurefire.redirectTestOutputToFile=false -Dsurefire.failIfNoSpecifiedTests=false -Dtest='AuditServiceTest'
  • ./mvnw verify -B -pl "dolphinscheduler-dao" -Dmaven.test.skip=false -Dspotless.skip=true -DskipUT=false -Danalyze.skip=true -Djacoco.skip=true -Dsurefire.printSummary=true -Dsurefire.useFile=false -Dsurefire.reportFormat=plain -Dsurefire.redirectTestOutputToFile=false -Dsurefire.failIfNoSpecifiedTests=false -Dtest='AuditLogMapperTest'
  • ./mvnw spotless:check -B -pl "dolphinscheduler-dao,dolphinscheduler-api"

Pull Request Notice

Pull Request Notice

qiuyanjun888 avatar Jun 22 '26 07:06 qiuyanjun888

cc @ruanwenjun

SbloodyS avatar Jun 24 '26 03:06 SbloodyS