@Test public void testAdmin() { KafkaPrincipal admin = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, "admin"); RequestChannel.Session host1Session = new RequestChannel.Session(admin, testHostName1); RequestChannel.Session host2Session = new RequestChannel.Session(admin, testHostName2); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Create"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Describe"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("ClusterAction"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Read"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Write"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Create"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Delete"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Alter"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("Describe"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host1Session, Operation$.MODULE$.fromString("ClusterAction"),topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Create"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Describe"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("ClusterAction"), clusterResource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Read"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Write"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Create"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Delete"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Alter"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("Describe"), topic1Resource)); Assert.assertTrue("Test failed.", authorizer.authorize(host2Session, Operation$.MODULE$.fromString("ClusterAction"), topic1Resource)); }
@Override public boolean authorize(RequestChannel.Session session, Operation operation, Resource resource) { LOG.debug("Authorizing Session: " + session + " for Operation: " + operation + " on Resource: " + resource); final KafkaPrincipal user = session.principal(); if (isSuperUser(user)) { LOG.debug("Allowing SuperUser: " + user + " in " + session + " for Operation: " + operation + " on Resource: " + resource); return true; } LOG.debug("User: " + user + " is not a SuperUser"); return binding.authorize(session, operation, resource); }
SentryKafkaAuthorizer implements Authorizer { @Override public boolean authorize(RequestChannel.Session session, Operation operation, Resource resource) { LOG.debug("Authorizing Session: " + session + " for Operation: " + operation + " on Resource: " + resource); final KafkaPrincipal user = session.principal(); if (isSuperUser(user)) { LOG.debug("Allowing SuperUser: " + user + " in " + session + " for Operation: " + operation + " on Resource: " + resource); return true; } LOG.debug("User: " + user + " is not a SuperUser"); return binding.authorize(session, operation, resource); } }
SentryKafkaAuthorizer implements Authorizer { @Override public boolean authorize(RequestChannel.Session session, Operation operation, Resource resource) { LOG.debug("Authorizing Session: " + session + " for Operation: " + operation + " on Resource: " + resource); final KafkaPrincipal user = session.principal(); if (isSuperUser(user)) { LOG.debug("Allowing SuperUser: " + user + " in " + session + " for Operation: " + operation + " on Resource: " + resource); return true; } LOG.debug("User: " + user + " is not a SuperUser"); return binding.authorize(session, operation, resource); } SentryKafkaAuthorizer(); }
SentryKafkaAuthorizer implements Authorizer { @Override public boolean authorize(RequestChannel.Session session, Operation operation, Resource resource) { LOG.debug("Authorizing Session: " + session + " for Operation: " + operation + " on Resource: " + resource); final KafkaPrincipal user = session.principal(); if (isSuperUser(user)) { LOG.debug("Allowing SuperUser: " + user + " in " + session + " for Operation: " + operation + " on Resource: " + resource); return true; } LOG.debug("User: " + user + " is not a SuperUser"); return binding.authorize(session, operation, resource); } SentryKafkaAuthorizer(); @Override boolean authorize(RequestChannel.Session session, Operation operation,
                           Resource resource); @Override void addAcls(Set<Acl> acls, final Resource resource); @Override boolean removeAcls(Set<Acl> acls, final Resource resource); @Override boolean removeAcls(final Resource resource); @Override Set<Acl> getAcls(Resource resource); @Override Map<Resource, Set<Acl>> getAcls(KafkaPrincipal principal); @Override Map<Resource, Set<Acl>> getAcls(); @Override void close(); @Override void configure(java.util.Map<String, ?> configs); void addRole(String role); void addRoleToGroups(String role, java.util.Set<String> groups); void dropAllRoles(); }
SentryKafkaAuthorizer implements Authorizer { @Override public boolean authorize(RequestChannel.Session session, Operation operation, Resource resource) { LOG.debug("Authorizing Session: " + session + " for Operation: " + operation + " on Resource: " + resource); final KafkaPrincipal user = session.principal(); if (isSuperUser(user)) { LOG.debug("Allowing SuperUser: " + user + " in " + session + " for Operation: " + operation + " on Resource: " + resource); return true; } LOG.debug("User: " + user + " is not a SuperUser"); return binding.authorize(session, operation, resource); } SentryKafkaAuthorizer(); @Override boolean authorize(RequestChannel.Session session, Operation operation,
                           Resource resource); @Override void addAcls(Set<Acl> acls, final Resource resource); @Override boolean removeAcls(Set<Acl> acls, final Resource resource); @Override boolean removeAcls(final Resource resource); @Override Set<Acl> getAcls(Resource resource); @Override Map<Resource, Set<Acl>> getAcls(KafkaPrincipal principal); @Override Map<Resource, Set<Acl>> getAcls(); @Override void close(); @Override void configure(java.util.Map<String, ?> configs); void addRole(String role); void addRoleToGroups(String role, java.util.Set<String> groups); void dropAllRoles();  }