sheetalshah1007 opened a new pull request, #770:
URL: https://github.com/apache/atlas/pull/770
## Summary
The v1 endpoint `GET /api/atlas/entities/{guid}/audit` returned entity audit
history after login only. It did not apply the same entity read authorization
as v2, so an authenticated user without entity read access could read audit
events (including attribute snapshots) if they knew the GUID.
This change applies the same entity read check used by v2 audit before any
audit events are returned from v1.
## Changes
- **EntityREST:** Moved the v2 audit authorization logic into
`verifyEntityReadForAudit(guid)`. For an active entity it uses `getHeaderById`;
for a purged entity it loads the header from the purge audit record and checks
entity read access. v2 `getAuditEvents` calls this helper only; behavior is
unchanged.
- **EntityResource:** v1 `getAuditEvents` calls
`verifyEntityReadForAudit(guid)` before reading from the audit repository.
- **EntityResource:** Authorization and not-found errors from
`AtlasBaseException` are converted with `toWebApplicationException`, matching
other v1 entity APIs (403 when read is denied).
- **EntityResourceTest:** New test confirms a denied entity read returns 403
and `listEvents` is not invoked.
## Test plan
**Unit tests**
```bash
mvn -pl webapp test
-Dtest=EntityResourceTest,EntityRESTTest#testGetAuditEvents_handlesPurgedEntity_Success
\
-Drat.skip=true -DskipEnunciate=true
```
- `EntityResourceTest.testGetAuditEvents_deniedWhenEntityReadNotAllowed` —
pass
- `EntityRESTTest.testGetAuditEvents_handlesPurgedEntity_Success` — pass
(purged-entity auth path on v2, shared helper)
**Manual (file auth + simple authorizer)**
- Users: `admin` (in `userRoles` → `ROLE_ADMIN`); `bob` in
`users-credentials.properties`, not in `userRoles`.
- **Active entity** (`hive_db`, known GUID):
- Bob: `GET /api/atlas/v2/entity/guid/{guid}` → **403**
- Bob: `GET /api/atlas/v2/entity/{guid}/audit` → **403**
- Bob: `GET /api/atlas/entities/{guid}/audit` → **403** (previously
**200**)
- No auth: v1 audit → **401**
- **Purged entity** (create → `DELETE /api/atlas/v2/entity/bulk?guid=...` →
`PUT /api/atlas/admin/purge`):
- Bob: v2 audit → **403**; v1 audit → **403**
- Admin: v2 entity read → **404** (entity removed from graph)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]