Search in sources :

Example 1 with HadoopDefaultAuthenticator

use of org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator in project hive by apache.

the class TestSQLStdHiveAccessControllerCLI method testConfigProcessing.

/**
   * Test that SQLStdHiveAccessController is not applying config restrictions on CLI
   *
   * @throws HiveAuthzPluginException
   */
@Test
public void testConfigProcessing() throws HiveAuthzPluginException {
    HiveConf processedConf = new HiveConf();
    SQLStdHiveAccessController accessController = new SQLStdHiveAccessController(null, processedConf, new HadoopDefaultAuthenticator(), getCLISessionCtx());
    accessController.applyAuthorizationConfigPolicy(processedConf);
    // check that hook to disable transforms has not been added
    assertFalse("Check for transform query disabling hook", processedConf.getVar(ConfVars.PREEXECHOOKS).contains(DisallowTransformHook.class.getName()));
    // verify that some dummy param can be set
    processedConf.verifyAndSet("dummy.param", "dummy.val");
    processedConf.verifyAndSet(ConfVars.HIVE_AUTHORIZATION_ENABLED.varname, "true");
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator) Test(org.junit.Test)

Example 2 with HadoopDefaultAuthenticator

use of org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator in project hive by apache.

the class TestSQLStdHiveAccessControllerHS2 method testConfigProcessing.

/**
   * Test if SQLStdHiveAccessController is applying configuration security
   * policy on hiveconf correctly
   *
   * @throws HiveAuthzPluginException
   * @throws IllegalAccessException
   * @throws NoSuchFieldException
   * @throws IllegalArgumentException
   * @throws SecurityException
   */
@Test
public void testConfigProcessing() throws HiveAuthzPluginException, SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    HiveConf processedConf = newAuthEnabledConf();
    SQLStdHiveAccessController accessController = new SQLStdHiveAccessController(null, processedConf, new HadoopDefaultAuthenticator(), getHS2SessionCtx());
    accessController.applyAuthorizationConfigPolicy(processedConf);
    // check that hook to disable transforms has been added
    assertTrue("Check for transform query disabling hook", processedConf.getVar(ConfVars.PREEXECHOOKS).contains(DisallowTransformHook.class.getName()));
    List<String> settableParams = getSettableParams();
    verifyParamSettability(settableParams, processedConf);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator) Test(org.junit.Test)

Example 3 with HadoopDefaultAuthenticator

use of org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator in project hive by apache.

the class TestSQLStdHiveAccessControllerHS2 method verifySettability.

private void verifySettability(List<String> paramRegexes, List<String> settableParams, ConfVars whiteListParam) throws HiveAuthzPluginException {
    HiveConf processedConf = newAuthEnabledConf();
    processedConf.setVar(whiteListParam, Joiner.on("|").join(paramRegexes));
    SQLStdHiveAccessController accessController = new SQLStdHiveAccessController(null, processedConf, new HadoopDefaultAuthenticator(), getHS2SessionCtx());
    accessController.applyAuthorizationConfigPolicy(processedConf);
    verifyParamSettability(settableParams, processedConf);
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator)

Example 4 with HadoopDefaultAuthenticator

use of org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator in project hive by apache.

the class TestHiveAuthorizationTaskFactory method setup.

@Before
public void setup() throws Exception {
    queryState = new QueryState(null);
    HiveConf conf = queryState.getConf();
    conf.setVar(ConfVars.HIVE_AUTHORIZATION_TASK_FACTORY, TestHiveAuthorizationTaskFactory.DummyHiveAuthorizationTaskFactoryImpl.class.getName());
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    db = Mockito.mock(Hive.class);
    table = new Table(DB, TABLE);
    partition = new Partition(table);
    SessionState.start(conf);
    context = new Context(conf);
    parseDriver = new ParseDriver();
    analyzer = new DDLSemanticAnalyzer(queryState, db);
    Mockito.when(db.getTable(DB, TABLE, false)).thenReturn(table);
    Mockito.when(db.getTable(TABLE_QNAME, false)).thenReturn(table);
    Mockito.when(db.getPartition(table, new HashMap<String, String>(), false)).thenReturn(partition);
    HadoopDefaultAuthenticator auth = new HadoopDefaultAuthenticator();
    auth.setConf(conf);
    currentUser = auth.getUserName();
    DummyHiveAuthorizationTaskFactoryImpl.reset();
}
Also used : Context(org.apache.hadoop.hive.ql.Context) Partition(org.apache.hadoop.hive.ql.metadata.Partition) Hive(org.apache.hadoop.hive.ql.metadata.Hive) Table(org.apache.hadoop.hive.ql.metadata.Table) ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) QueryState(org.apache.hadoop.hive.ql.QueryState) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator) DDLSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer) Before(org.junit.Before)

Example 5 with HadoopDefaultAuthenticator

use of org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator in project hive by apache.

the class TestSQLStdHiveAccessControllerCLI method testAuthEnable.

/**
   * Verify that no exception is thrown if authorization is enabled from hive cli,
   * when sql std auth is used
   */
@Test
public void testAuthEnable() throws Exception {
    HiveConf processedConf = new HiveConf();
    processedConf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
    HiveAuthorizerFactory authorizerFactory = new SQLStdHiveAuthorizerFactory();
    HiveAuthorizer authorizer = authorizerFactory.createHiveAuthorizer(null, processedConf, new HadoopDefaultAuthenticator(), getCLISessionCtx());
}
Also used : HiveAuthorizerFactory(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizerFactory) HiveAuthorizer(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizer) HiveConf(org.apache.hadoop.hive.conf.HiveConf) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator) Test(org.junit.Test)

Aggregations

HiveConf (org.apache.hadoop.hive.conf.HiveConf)5 HadoopDefaultAuthenticator (org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator)5 Test (org.junit.Test)3 Context (org.apache.hadoop.hive.ql.Context)1 QueryState (org.apache.hadoop.hive.ql.QueryState)1 Hive (org.apache.hadoop.hive.ql.metadata.Hive)1 Partition (org.apache.hadoop.hive.ql.metadata.Partition)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 DDLSemanticAnalyzer (org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer)1 ParseDriver (org.apache.hadoop.hive.ql.parse.ParseDriver)1 HiveAuthorizer (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizer)1 HiveAuthorizerFactory (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizerFactory)1 Before (org.junit.Before)1