Skip to content

Commit

Permalink
[apache#5675] feat(auth): Relational chained authorization plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
xunliu committed Nov 28, 2024
1 parent b953226 commit b087a97
Show file tree
Hide file tree
Showing 31 changed files with 1,090 additions and 40 deletions.
97 changes: 97 additions & 0 deletions authorizations/authorization-chain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
description = "authorization-ranger"

plugins {
`maven-publish`
id("java")
id("idea")
}

dependencies {
implementation(project(":api")) {
exclude(group = "*")
}
implementation(project(":core")) {
exclude(group = "*")
}
implementation(project(":common")) {
exclude(group = "*")
}

implementation(libs.bundles.log4j)
implementation(libs.commons.lang3)
implementation(libs.guava)
implementation(libs.javax.jaxb.api) {
exclude("*")
}
implementation(libs.javax.ws.rs.api)
implementation(libs.jettison)
compileOnly(libs.lombok)
implementation(libs.rome)

testImplementation(project(":core", "testArtifacts"))
testImplementation(project(":clients:client-java"))
testImplementation(project(":server"))
testImplementation(project(":catalogs:catalog-common"))
testImplementation(project(":integration-test-common", "testArtifacts"))
testImplementation(libs.junit.jupiter.api)
testImplementation(libs.mockito.core)
testImplementation(libs.testcontainers)
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(libs.mysql.driver)
testImplementation(libs.postgresql.driver)
}

tasks {
val runtimeJars by registering(Copy::class) {
from(configurations.runtimeClasspath)
into("build/libs")
}

val copyAuthorizationLibs by registering(Copy::class) {
dependsOn("jar", runtimeJars)
from("build/libs") {
exclude("guava-*.jar")
exclude("log4j-*.jar")
exclude("slf4j-*.jar")
}
into("$rootDir/distribution/package/authorizations/chain/libs")
}

register("copyLibAndConfig", Copy::class) {
dependsOn(copyAuthorizationLibs)
}

jar {
dependsOn(runtimeJars)
}
}

tasks.test {
dependsOn(":catalogs:catalog-hive:jar", ":catalogs:catalog-hive:runtimeJars")

val skipITs = project.hasProperty("skipITs")
if (skipITs) {
// Exclude integration tests
exclude("**/integration/test/**")
} else {
dependsOn(tasks.jar)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.gravitino.authorization.chain;

import java.util.Map;
import org.apache.gravitino.connector.authorization.AuthorizationPlugin;
import org.apache.gravitino.connector.authorization.BaseAuthorization;

/** Implementation of a Chain authorization in Gravitino. */
public class ChainAuthorization extends BaseAuthorization<ChainAuthorization> {
@Override
public String shortName() {
return "chain";
}

@Override
protected AuthorizationPlugin newPlugin(String catalogProvider, Map<String, String> config) {
switch (catalogProvider) {
case "hive":
case "test": // For testing purposes
return ChainAuthorizationPlugin.getInstance(catalogProvider, config);
default:
throw new IllegalArgumentException("Unknown catalog provider: " + catalogProvider);
}
}
}
Loading

0 comments on commit b087a97

Please sign in to comment.