ATLAS-5388: Add topic-scoped authorization for REST notification POST. - #753
Open
UmeshPatil-1 wants to merge 1 commit into
Open
ATLAS-5388: Add topic-scoped authorization for REST notification POST.#753UmeshPatil-1 wants to merge 1 commit into
UmeshPatil-1 wants to merge 1 commit into
Conversation
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.
What changes were proposed in this pull request?
Problem
The
rest-notification-webappmodule (port 41000) exposesPOST /rest/api/atlas/v2/notification/topic/{topicName}as the REST ingress for hook messages to Kafka.Authorization on this endpoint uses an admin-shaped check that ignores the URL topic:
AtlasAdminAccessRequestSERVICE_NOTIFICATION_POST(service-notification-post)topicNameignoredATLAS_HOOK.)ATLAS_HOOKonly)notification-topicresource in Atlas service-def (follow-up: RANGER-5759)Affected endpoint:
topicName examples:
ATLAS_HOOK,Solution
This PR introduces topic-scoped authorization so the
topicNamepath parameter participates in the allow/deny decision.1. New request type and privilege (authorization module)
New file:
authorization/src/main/java/org/apache/atlas/authorize/AtlasNotificationRequest.javaCarries
topicNameinto the authorization layer (parallel toAtlasEntityAccessRequest,AtlasTypeAccessRequest).New file:
authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizeConstants.javaDefines
NOTIFICATION_TOPIC_RESOURCE_TYPE = "notification-topic"for Ranger alignment (RANGER-5759).File:
authorization/src/main/java/org/apache/atlas/authorize/AtlasPrivilege.javaRenamed privilege:
File:
authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizer.javaAdded authorizer contract (default deny):
Files:
AtlasAuthorizationUtils.java,AtlasNoneAuthorizer.javaAdded
verifyAccess/isAccessAllowedforAtlasNotificationRequest.2. Simple authorizer — topic-scoped policy model
File:
authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasSimpleAuthzPolicy.javaAdded
AtlasNotificationPermissionwith:privileges["post-notification"]or[".*"]topicNames["ATLAS_HOOK"]or[".*"]File:
authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasSimpleAuthorizer.javaMatches both privilege and topic (wildcard/regex supported):
Policy files updated:
authorization/src/main/resources/atlas-simple-authz-policy.jsonROLE_ADMINwildcard +HIVE_HOOK_SERVICEexample roleauthorization/src/test/resources/atlas-simple-authz-policy.jsonhivehookuserdistro/src/conf/atlas-simple-authz-policy.jsonExample — topic-scoped hook user:
3. REST ingress — topic-aware authorization
File:
rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.javaReplaced admin-level check with topic-scoped request:
Effect: Authorization evaluates the specific topic from the URL. A user scoped to
ATLAS_HOOKreceives 403 when posting toATLAS_ENTITIES.4. Unit tests
File:
authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasSimpleAuthorizerTest.javaAdded 4 tests for admin allow, data-scientist deny, hivehook topic allow, and hivehook cross-topic deny.
Build
mvn clean install -DskipITs=true
Result: BUILD SUCCESS. All modules.
Unit tests
Result:
Tests run: Failures: 0, Errors: 0, Skipped: 0— BUILD SUCCESStestPostNotificationAllowedForAdminUsertestPostNotificationDeniedForDataScientistUsertestPostNotificationAllowedForTopicSpecificRoletestPostNotificationDeniedForTopicSpecificRoleOnOtherTopicManual / integration tests (local)
Test users:
ATLAS_HOOKonly)Endpoint tested:
Baseline test results (port 41000)
/topic/ATLAS_HOOKCore ATLAS-5388 test results (topic-scoped authorization)
/topic/ATLAS_HOOK/topic/ATLAS_HOOK/topic/ATLAS_ENTITIES/topic/ATLAS_ENTITIESJIRA minimum acceptance criteria met:
ATLAS_HOOKATLAS_ENTITIESNo UI changes in this PR.
Related