[Improvement-17933][api] Restrict audit logs to current user for non-admin users#18368
Merged
Conversation
Member
|
cc @ruanwenjun |
Pass the login user context into audit log queries and restrict non-admin users to their own audit log records while preserving the global audit view for administrators.
71975a9 to
bca24cc
Compare
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.
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
AuditLogControllertoAuditService.userIdfilter toAuditLogMapper.queryAuditLog.userIdfiltering for non-admin users and keep admin queries global.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