Repository navigation
[Server] Audit records for permission changes #2029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e84542a
15399f7
3084d55
a631425
81d6c87
8fbc8df
4fbb2ef
fa84727
7a5e96c
06bf638
e2c85ed
4bceff3
9980d07
532358e
a04d26f
d2414f4
d86843d
8986ec3
00bc15e
ebb1b6c
e783783
2d9f0ef
637e94e
b750a16
5eb0107
9d2923b
79b3a79
bb57288
bca133b
5d625b1
81626c2
ff632a0
996484c
9ecc225
760c242
820ba3a
5287506
864fef3
c7bd7a1
8dbb138
b2a1790
e9cada6
2c475da
176bf2e
4211d4f
01ddf30
cbc5461
a24cf7c
87ab99d
b4a7f31
85f92c1
f1ab118
c254428
bf0d66b
dacf303
2e303a8
86b0e0c
0f7e6dd
446762a
99ba889
3beef7a
95726ab
4a29cb4
0f832c5
5d1d997
5f1d0a9
1e2b0aa
05c3a79
d0f7d06
a3f4771
7a8769f
529e9db
cdf90e3
5478e64
e98ca9b
f94da72
2b9714b
ace90e3
28288dd
2632419
6f20820
2012ae5
f4a3350
64288dc
036a80c
b7911b7
9403266
efd7c75
cd3b9d9
1f4b974
06e3e02
e020887
043aad6
50d8d99
efb86a1
26ffb3a
0699deb
1809cde
d1bb455
5ea525b
4da9394
36f5c7c
897832a
fefbad6
04008ff
91f0884
f581cca
bbed4f7
cf57b06
fad9e62
9c3a95b
549edb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| package io.unitycatalog.server.audit; | ||
|
|
||
| import io.unitycatalog.server.auth.UnityCatalogAuthorizer; | ||
| import io.unitycatalog.server.model.SecurableType; | ||
| import io.unitycatalog.server.persist.model.Privileges; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
|
|
||
| /** Records each permission change, as described on {@link Auditor#wrap(UnityCatalogAuthorizer)}. */ | ||
| final class AuditingAuthorizer implements UnityCatalogAuthorizer, AutoCloseable { | ||
| private final UnityCatalogAuthorizer delegate; | ||
| private final Auditor auditor; | ||
|
|
||
| AuditingAuthorizer(UnityCatalogAuthorizer delegate, Auditor auditor) { | ||
| this.delegate = delegate; | ||
| this.auditor = auditor; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean grantAuthorization(UUID principal, UUID resource, Privileges action) { | ||
| boolean changed = delegate.grantAuthorization(principal, resource, action); | ||
| if (changed) { | ||
| auditor.recordPermission(AuditRecord.Action.GRANT, principal, resource, action); | ||
| } | ||
| return changed; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean revokeAuthorization(UUID principal, UUID resource, Privileges action) { | ||
| boolean changed = delegate.revokeAuthorization(principal, resource, action); | ||
| // Recorded whatever the flag says. In jCasbin, removePolicy and removeFilteredPolicy | ||
| // delete the rows through the adapter before they check the in-memory model, so a server that | ||
| // has not reloaded the policy deletes the rows and still returns false. A failed delete throws. | ||
| auditor.recordPermission(AuditRecord.Action.REVOKE, principal, resource, action); | ||
| return changed; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean clearAuthorizationsForPrincipal(UUID principal) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Assisted] Not a blocker, the behavior is right today. Only revoke is tested with a |
||
| boolean changed = delegate.clearAuthorizationsForPrincipal(principal); | ||
| auditor.recordPermission(AuditRecord.Action.CLEAR_PRINCIPAL_GRANTS, principal, null, null); | ||
| return changed; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean clearAuthorizationsForResource(UUID resource) { | ||
| boolean changed = delegate.clearAuthorizationsForResource(resource); | ||
| auditor.recordPermission(AuditRecord.Action.CLEAR_RESOURCE_GRANTS, null, resource, null); | ||
| return changed; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean addHierarchyChild(UUID parent, UUID child) { | ||
| return delegate.addHierarchyChild(parent, child); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean removeHierarchyChild(UUID parent, UUID child) { | ||
| return delegate.removeHierarchyChild(parent, child); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean removeHierarchyChildren(UUID resource) { | ||
| return delegate.removeHierarchyChildren(resource); | ||
| } | ||
|
|
||
| @Override | ||
| public UUID getHierarchyParent(UUID resource) { | ||
| return delegate.getHierarchyParent(resource); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean authorize( | ||
| UUID principal, SecurableType resourceType, UUID resource, Privileges action) { | ||
| return delegate.authorize(principal, resourceType, resource, action); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean authorizeAny( | ||
| UUID principal, SecurableType resourceType, UUID resource, Privileges... actions) { | ||
| return delegate.authorizeAny(principal, resourceType, resource, actions); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean authorizeAll( | ||
| UUID principal, SecurableType resourceType, UUID resource, Privileges... actions) { | ||
| return delegate.authorizeAll(principal, resourceType, resource, actions); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Privileges> listAuthorizations(UUID principal, UUID resource) { | ||
| return delegate.listAuthorizations(principal, resource); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<UUID, List<Privileges>> listAuthorizations(UUID resource) { | ||
| return delegate.listAuthorizations(resource); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean refreshAuthorizations(long operationStartNanos) { | ||
| return delegate.refreshAuthorizations(operationStartNanos); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws Exception { | ||
| if (delegate instanceof AutoCloseable closeable) { | ||
| closeable.close(); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.