Skip to content

Commit b084ba2

Browse files
committed
NoSQL persistence
1 parent 107d590 commit b084ba2

File tree

326 files changed

+28426
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+28426
-29
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ License: https://www.apache.org/licenses/LICENSE-2.0
230230

231231
--------------------------------------------------------------------------------
232232

233+
This product includes code from Netty.
234+
235+
* persistence/nosql/persistence/cdi/quarkus-distcache/src/main/java/org/apache/polaris/persistence/nosql/quarkus/distcache/ResolvConf.java
236+
237+
Copyright: Copyright © 2025 The Netty project
238+
Home page: https://netty.io/
239+
License: https://www.apache.org/licenses/LICENSE-2.0
240+
241+
--------------------------------------------------------------------------------
242+
233243
This product includes code from OpenAPITool openapi-generator
234244

235245
* server-templates/formParams.mustache
@@ -328,6 +338,9 @@ This product includes code from Project Nessie.
328338
* helm/polaris/templates/servicemonitor.yaml
329339
* helm/polaris/templates/storage.yaml
330340

341+
Code underneath the components/persistence directory, especially pluggable object types, index related, cache,
342+
atomic commit logic and fundamental persistence implementations.
343+
331344
Copyright: Copyright 2015-2025 Dremio Corporation
332345
Home page: https://projectnessie.org/
333346
License: https://www.apache.org/licenses/LICENSE-2.0

bom/build.gradle.kts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ dependencies {
4747
api(project(":polaris-nodes-api"))
4848
api(project(":polaris-nodes-impl"))
4949
api(project(":polaris-nodes-spi"))
50+
api(project(":polaris-nodes-store-nosql"))
51+
52+
api(project(":polaris-realms-api"))
53+
api(project(":polaris-realms-impl"))
54+
api(project(":polaris-realms-spi"))
55+
api(project(":polaris-realms-store-nosql"))
56+
57+
api(project(":polaris-authz-api"))
58+
api(project(":polaris-authz-impl"))
59+
api(project(":polaris-authz-spi"))
60+
api(project(":polaris-authz-store-nosql"))
61+
62+
api(project(":polaris-persistence-nosql-api"))
63+
api(project(":polaris-persistence-nosql-impl"))
64+
api(project(":polaris-persistence-nosql-benchmark"))
65+
api(project(":polaris-persistence-nosql-metastore"))
66+
api(project(":polaris-persistence-nosql-cdi-common"))
67+
api(project(":polaris-persistence-nosql-cdi-quarkus"))
68+
api(project(":polaris-persistence-nosql-cdi-quarkus-distcache"))
69+
api(project(":polaris-persistence-nosql-cdi-weld"))
70+
api(project(":polaris-persistence-nosql-correctness"))
71+
api(project(":polaris-persistence-nosql-standalone"))
72+
api(project(":polaris-persistence-nosql-testextension"))
73+
api(project(":polaris-persistence-nosql-types"))
74+
75+
api(project(":polaris-persistence-nosql-inmemory"))
76+
api(project(":polaris-persistence-nosql-mongodb"))
77+
78+
api(project(":polaris-persistence-nosql-maintenance-api"))
79+
api(project(":polaris-persistence-nosql-maintenance-impl"))
80+
api(project(":polaris-persistence-nosql-maintenance-cel"))
81+
api(project(":polaris-persistence-nosql-maintenance-spi"))
5082

5183
api(project(":polaris-persistence-nosql-api"))
5284
api(project(":polaris-persistence-nosql-impl"))

codestyle/checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<!-- Checks for imports -->
4444
<!-- See http://checkstyle.org/config_imports.html -->
4545
<module name="IllegalImport">
46-
<property name="illegalPkgs" value=".*\.shaded\..*, .*\.relocated\..*"/>
46+
<property name="illegalPkgs" value=".*\.shaded\..*, (?!org\.projectnessie\.cel).*\.relocated\..*"/>
4747
<property name="regexp" value="true"/>
4848
</module>
4949

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ awssdk-bom = { module = "software.amazon.awssdk:bom", version = "2.37.3" }
4848
awaitility = { module = "org.awaitility:awaitility", version = "4.3.0" }
4949
azuresdk-bom = { module = "com.azure:azure-sdk-bom", version = "1.3.2" }
5050
caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version = "3.2.3" }
51+
cel-bom = { module = "org.projectnessie.cel:cel-bom", version = "0.5.3" }
5152
commons-lang3 = { module = "org.apache.commons:commons-lang3", version = "3.19.0" }
5253
commons-text = { module = "org.apache.commons:commons-text", version = "1.14.0" }
54+
docker-java-api = { module = "com.github.docker-java:docker-java-api", version = "3.6.0" }
5355
errorprone = { module = "com.google.errorprone:error_prone_core", version = "2.43.0" }
5456
google-cloud-storage-bom = { module = "com.google.cloud:google-cloud-storage-bom", version = "2.59.0" }
5557
guava = { module = "com.google.guava:guava", version = "33.5.0-jre" }
@@ -74,12 +76,12 @@ jakarta-servlet-api = { module = "jakarta.servlet:jakarta.servlet-api", version
7476
jakarta-validation-api = { module = "jakarta.validation:jakarta.validation-api", version = "3.1.1" }
7577
jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version = "4.0.0" }
7678
javax-servlet-api = { module = "javax.servlet:javax.servlet-api", version = "4.0.1" }
77-
junit-bom = { module = "org.junit:junit-bom", version = "5.14.1" }
78-
junit-pioneer = { module = "org.junit-pioneer:junit-pioneer", version = "2.3.0" }
79-
keycloak-admin-client = { module = "org.keycloak:keycloak-admin-client", version = "26.0.7" }
8079
jcstress-core = { module = "org.openjdk.jcstress:jcstress-core", version = "0.16" }
8180
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
8281
jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
82+
junit-bom = { module = "org.junit:junit-bom", version = "5.14.1" }
83+
junit-pioneer = { module = "org.junit-pioneer:junit-pioneer", version = "2.3.0" }
84+
keycloak-admin-client = { module = "org.keycloak:keycloak-admin-client", version = "26.0.7" }
8385
logback-classic = { module = "ch.qos.logback:logback-classic", version = "1.5.20" }
8486
micrometer-bom = { module = "io.micrometer:micrometer-bom", version = "1.16.0" }
8587
microprofile-fault-tolerance-api = { module = "org.eclipse.microprofile.fault-tolerance:microprofile-fault-tolerance-api", version = "4.1.2" }

gradle/projects.main.properties

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,36 @@ polaris-idgen-spi=persistence/nosql/idgen/spi
6262
polaris-nodes-api=persistence/nosql/nodes/api
6363
polaris-nodes-impl=persistence/nosql/nodes/impl
6464
polaris-nodes-spi=persistence/nosql/nodes/spi
65+
polaris-nodes-store-nosql=persistence/nosql/nodes/store-nosql
66+
# realms
67+
polaris-realms-api=persistence/nosql/realms/api
68+
polaris-realms-impl=persistence/nosql/realms/impl
69+
polaris-realms-spi=persistence/nosql/realms/spi
70+
polaris-realms-store-nosql=persistence/nosql/realms/store-nosql
71+
# authz
72+
polaris-authz-api=persistence/nosql/authz/api
73+
polaris-authz-impl=persistence/nosql/authz/impl
74+
polaris-authz-spi=persistence/nosql/authz/spi
75+
polaris-authz-store-nosql=persistence/nosql/authz/store-nosql
6576
# persistence / database agnostic
6677
polaris-persistence-nosql-api=persistence/nosql/persistence/api
6778
polaris-persistence-nosql-impl=persistence/nosql/persistence/impl
79+
polaris-persistence-nosql-benchmark=persistence/nosql/persistence/benchmark
80+
polaris-persistence-nosql-metastore=persistence/nosql/persistence/metastore
81+
polaris-persistence-nosql-cdi-common=persistence/nosql/persistence/cdi/common
82+
polaris-persistence-nosql-cdi-quarkus=persistence/nosql/persistence/cdi/quarkus
83+
polaris-persistence-nosql-cdi-quarkus-distcache=persistence/nosql/persistence/cdi/quarkus-distcache
84+
polaris-persistence-nosql-cdi-weld=persistence/nosql/persistence/cdi/weld
85+
polaris-persistence-nosql-correctness=persistence/nosql/persistence/correctness
6886
polaris-persistence-nosql-standalone=persistence/nosql/persistence/standalone
6987
polaris-persistence-nosql-testextension=persistence/nosql/persistence/testextension
88+
polaris-persistence-nosql-types=persistence/nosql/persistence/types
7089
polaris-persistence-nosql-varint=persistence/nosql/persistence/varint
90+
# persistence / maintenance
91+
polaris-persistence-nosql-maintenance-api=persistence/nosql/persistence/maintenance/api
92+
polaris-persistence-nosql-maintenance-impl=persistence/nosql/persistence/maintenance/impl
93+
polaris-persistence-nosql-maintenance-cel=persistence/nosql/persistence/maintenance/retain-cel
94+
polaris-persistence-nosql-maintenance-spi=persistence/nosql/persistence/maintenance/spi
7195
# persistence / database specific implementations
7296
polaris-persistence-nosql-inmemory=persistence/nosql/persistence/db/inmemory
7397
polaris-persistence-nosql-mongodb=persistence/nosql/persistence/db/mongodb

persistence/nosql/authz/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# AuthZ framework with pluggable privileges
21+
22+
Provides a framework and implementations pluggable privileges and privilege checks.
23+
24+
## Privileges
25+
26+
A privilege is globally identified by its name. Privileges can be inheritable (from its parents) or not. Multiple
27+
privileges can be grouped together to a _composite_ privilege (think: `ALL_DML` having `SELECT`, `INSERT`, `UPDATE` and
28+
`DELETE`) - a composite privilege matches, if all its individual privileges match. Multiple privileges can also be
29+
grouped to an _alternative_ privilege, which matches if any of its individual privileges matches.
30+
31+
Available privileges are provided by one or more `PrivilegeProvider`s, which are discovered at runtime.
32+
Note: currently there is only one `ProvilegeProvider` that plugs in the Polaris privileges.
33+
34+
## ACLs, ACL entries and ACL chains
35+
36+
Each securable object can have its own ACL. ACLs consist of ACL entries, which define the _granted_ and _restricted_
37+
privileges by role name. The the number of roles is technically unbounded and the number of ACL entries can become
38+
quite large.
39+
40+
This framework implements [separation of duties](https://en.wikipedia.org/wiki/Separation_of_duties) ("SoD"), which is a
41+
quite demanded functionality not just by large(r) user organizations. TL;DR _SoD_ allows "security administrators" to
42+
grant and revoke privileges to other users, but not leverage those privileges themselves.
43+
44+
The _effective_ set of privileges for a specific operation performed by a specific caller needs to be computed against
45+
the target objects and their parents. _ACL chains_ are the vehicle to model this hierarchy and let the implementation
46+
compute the set of _effective_ privileges based on the individual ACLs and roles.
47+
48+
Note: Privilege checks and _SoD_ are currently not performed via this framework.
49+
50+
## Jackson support & Storage friendly representation
51+
52+
The persistable types `Acl`, `AclEntry`, and `PrivilegeSet` can all be serialized using Jackson.
53+
54+
As the number of ACL entries can become quite large, space efficient serialization is quite important. The
55+
implementation uses bit-set encoding when serializing `PrivilegeSet`s for persistence.
56+
57+
## Code structure
58+
59+
The code is structured into multiple modules. Consuming code should almost always pull in only the API module.
60+
61+
* `polaris-authz-api` provides the necessary Java interfaces and immutable types.
62+
* `polaris-authz-impl` provides the storage agnostic implementation.
63+
* `polaris-authz-spi` provides the necessary interfaces to provide custom privileges and storage implementation.
64+
* `polaris-authz-store-nosql` provides the storage implementation based on `polaris-persistence-nosql-api`.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
plugins {
21+
id("org.kordamp.gradle.jandex")
22+
id("polaris-server")
23+
}
24+
25+
description = "Polaris AuthZ API"
26+
27+
dependencies {
28+
implementation(libs.guava)
29+
30+
implementation(platform(libs.jackson.bom))
31+
implementation("com.fasterxml.jackson.core:jackson-databind")
32+
33+
compileOnly(libs.jakarta.annotation.api)
34+
compileOnly(libs.jakarta.validation.api)
35+
compileOnly(libs.jakarta.inject.api)
36+
compileOnly(libs.jakarta.enterprise.cdi.api)
37+
38+
compileOnly(project(":polaris-immutables"))
39+
annotationProcessor(project(":polaris-immutables", configuration = "processor"))
40+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.authz.api;
20+
21+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
22+
import jakarta.annotation.Nonnull;
23+
import java.util.Set;
24+
import java.util.function.BiConsumer;
25+
import java.util.function.Consumer;
26+
27+
public interface Acl {
28+
29+
void entriesForRoleIds(
30+
@Nonnull Set<String> roleIds, @Nonnull Consumer<AclEntry> aclEntryConsumer);
31+
32+
void forEach(@Nonnull BiConsumer<String, AclEntry> consumer);
33+
34+
interface AclBuilder {
35+
@CanIgnoreReturnValue
36+
AclBuilder from(@Nonnull Acl instance);
37+
38+
@CanIgnoreReturnValue
39+
AclBuilder addEntry(@Nonnull String roleId, @Nonnull AclEntry entry);
40+
41+
@CanIgnoreReturnValue
42+
AclBuilder removeEntry(@Nonnull String roleId);
43+
44+
/**
45+
* Add, remove or update an {@linkplain AclEntry ACL entry} for a role.
46+
*
47+
* <p>The {@linkplain Consumer consumer} is called with an empty builder, if no ACL entry for
48+
* the role exists, otherwise with a builder constructed from the existing entry. If the given
49+
* {@linkplain Consumer consumer} removes all privileges from the ACL entry, the ACL entry will
50+
* be removed.
51+
*/
52+
@CanIgnoreReturnValue
53+
AclBuilder modify(@Nonnull String roleId, @Nonnull Consumer<AclEntry.AclEntryBuilder> entry);
54+
55+
Acl build();
56+
}
57+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.authz.api;
20+
21+
import java.util.Optional;
22+
import org.apache.polaris.immutables.PolarisImmutable;
23+
import org.immutables.value.Value;
24+
25+
/** Container for an {@linkplain Acl ACL} of an individual entity and a pointer to its parent. */
26+
@PolarisImmutable
27+
public interface AclChain {
28+
@Value.Parameter(order = 1)
29+
Acl acl();
30+
31+
@Value.Parameter(order = 2)
32+
Optional<AclChain> parent();
33+
34+
static AclChain aclChain(Acl acl, Optional<AclChain> parent) {
35+
return ImmutableAclChain.of(acl, parent);
36+
}
37+
}

0 commit comments

Comments
 (0)