Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ protected RangerAccessRequestImpl createRequest(AuthorizedSubject subject, Acces
// granting - and denying - on policies this source has never matched, in every deployment that has
// any. That is a change to what an existing Ranger service decides and belongs with a release note
// of its own, not here.
//
// User groups are omitted for the same reason. Ranger already attaches UserStore groups during
// RangerDefaultRequestProcessor.preProcess() when the operator sets
// ranger.plugin.doris.use.rangerGroups=true in ranger-doris-security.xml. Calling setUserGroups()
// here would start matching group items in every deployment, including those that never opted in.
request.setClientIPAddress(clientAddressOf(subject, context));
request.setClusterType(CLIENT_TYPE_DORIS);
request.setClientType(CLIENT_TYPE_DORIS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@

package org.apache.doris.catalog.authorizer.ranger.doris;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.ranger.plugin.service.RangerAuthContextListener;
import org.apache.ranger.plugin.service.RangerBasePlugin;

public class RangerDorisPlugin extends RangerBasePlugin {
private static final Logger LOG = LogManager.getLogger(RangerDorisPlugin.class);

public RangerDorisPlugin(String serviceName) {
this(serviceName, null);
}

public RangerDorisPlugin(String serviceName, RangerAuthContextListener rangerAuthContextListener) {
super(serviceName, null, null);
super.init();
if (getConfig() != null && !getConfig().isUseRangerGroups()) {
LOG.info("Ranger UserStore groups are downloaded but not evaluated. Set "
+ "ranger.plugin.doris.use.rangerGroups=true in ranger-doris-security.xml to "
+ "enable group-based policies, row filters, and column masks.");
}
super.registerAuthContextEventListener(rangerAuthContextListener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
import org.apache.ranger.plugin.policyengine.RangerAccessResource;
import org.apache.ranger.plugin.policyengine.RangerAccessResult;
import org.apache.ranger.plugin.policyengine.RangerAccessResultProcessor;
Expand Down Expand Up @@ -353,4 +354,21 @@ public void testTheDefaultWorkloadGroupIsNotAskedAbout() throws AccessDeniedExce
Assertions.assertEquals(0, plugin.requests.get(),
"the default workload group was put to the policy engine");
}

/**
* Roles and groups stay off the request this source builds. Ranger-hive sends Doris roles; this
* source does not, and groups belong to Ranger's {@code use.rangerGroups} preprocessing, not to
* this builder. Putting either on the request would start matching policy items this source has
* never matched.
*/
@Test
public void testRequestDoesNotCarryRolesOrGroups() {
RangerAccessRequestImpl request = controller().createRequest(USER, AccessContext.NONE);

Assertions.assertEquals("user1", request.getUser());
Assertions.assertTrue(request.getUserGroups() == null || request.getUserGroups().isEmpty(),
"groups were attached in createRequest rather than left to Ranger preprocessing");
Assertions.assertTrue(request.getUserRoles() == null || request.getUserRoles().isEmpty(),
"roles were attached in createRequest, which this source has never done");
}
}
Loading