Skip to content

Commit 7cecfa9

Browse files
authored
Remove multitenancy (#3679)
* Remove multitenancy ui checks * Remove tenant id from sql storage * Remove multitenancy from sql storage * Remove multitenancy from kafkasql * Fix sql statements * Remove upgrade tests * Remove kafka sql upgrader * Simplify auto update version query
1 parent ba4b384 commit 7cecfa9

File tree

166 files changed

+1091
-7356
lines changed

Some content is hidden

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

166 files changed

+1091
-7356
lines changed

.github/workflows/integration-tests.yaml

-10
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ jobs:
115115
- name: Run Integration Tests - sql - migration
116116
run: make REGISTRY_IMAGE='-Dregistry-sql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-sql:1d' run-sql-migration-integration-tests
117117

118-
- name: Run Integration Tests - sql - db upgrade
119-
run: make REGISTRY_IMAGE='-Dregistry-sql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-sql:1d' run-sql-upgrade-tests
120-
121-
- name: Run Integration Tests - sql - multitenancy
122-
run: make REGISTRY_IMAGE='-Dregistry-sql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-sql:1d' run-sql-multitenancy-integration-tests
123-
124-
125118
- name: Collect logs
126119
if: failure()
127120
run: ./.github/scripts/collect_logs.sh
@@ -164,9 +157,6 @@ jobs:
164157
- name: Run Integration Tests - KafkaSql - Migration
165158
run: make REGISTRY_IMAGE='-Dregistry-kafkasql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-kafkasql:1d' run-kafkasql-migration-integration-tests
166159

167-
- name: Run Integration Tests - KafkaSql - DBUpgrade
168-
run: make REGISTRY_IMAGE='-Dregistry-kafkasql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-kafkasql:1d' run-kafkasql-upgrade-tests
169-
170160
- name: Run Integration Tests - KafkaSql - Auth
171161
run: make REGISTRY_IMAGE='-Dregistry-kafkasql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-kafkasql:1d' run-kafkasql-auth-tests
172162

.github/workflows/registry-rhbq-build.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ jobs:
7373
- name: Set test profile to all
7474
run: echo "test_profile=all" >> $GITHUB_ENV
7575

76-
- name: Prepare Tenant Manager
77-
run: make build-integration-tests-multitenancy
78-
7976
- name: Build integration-tests-common
8077
if: github.event.inputs.skip-tests == 'false'
8178
run: cd registry && ./mvnw install -Pintegration-tests -pl integration-tests/integration-tests-common

.github/workflows/verify.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,6 @@ jobs:
446446
- name: Run Integration Tests - sql migration
447447
run: make REGISTRY_IMAGE='-Dregistry-sql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-sql-native:1d' run-sql-migration-integration-tests
448448

449-
- name: Run Integration Tests - sql multitenancy
450-
run: make REGISTRY_IMAGE='-Dregistry-sql-image=ttl.sh/${{ github.sha }}/apicurio/apicurio-registry-sql-native:1d' run-sql-multitenancy-integration-tests
451-
452449
- name: Collect logs
453450
if: failure()
454451
run: ./.github/scripts/collect_logs.sh

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ website
2323
**/bin
2424

2525
apicurio-codegen
26-
/multitenancy/
2726
/docs/.jbang/
2827

2928
python-sdk/dist

Makefile

+1-39
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,6 @@ mem-native-scratch-image:
364364
.PHONY: multiarch-registry-images ## Builds and pushes multi-arch registry images for all variants. Variables available for override [IMAGE_REPO, IMAGE_TAG]
365365
multiarch-registry-images: mem-multiarch-images sql-multiarch-images mssql-multiarch-images kafkasql-multiarch-images mem-native-scratch-image gitops-multiarch-images
366366

367-
368-
.PHONY: pr-check ## Builds and runs basic tests for multitenant registry pipelines
369-
pr-check:
370-
CURRENT_ENV=mas mvn clean install -Pno-docker -Dskip.npm -Pprod -Psql -am -pl storage/sql \
371-
-Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false
372-
./scripts/clean-postgres.sh
373-
CURRENT_ENV=mas NO_DOCKER=true mvn verify -Pintegration-tests -Psql -am -pl integration-tests \
374-
-Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false
375-
376-
.PHONY: build-project ## Builds the components for multitenant registry pipelines
377-
build-project:
378-
# run unit tests for app module
379-
CURRENT_ENV=mas mvn clean install -Pno-docker -Dskip.npm -Pprod -Psql -am -pl app -Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false
380-
# build everything without running tests in order to be able to build container images
381-
CURRENT_ENV=mas mvn clean install -Pprod -Pno-docker -Dskip.npm -Psql -Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false -DskipTests
382-
383-
384367
.PHONY: run-ui-tests ## Runs ui e2e tests
385368
run-ui-tests:
386369
@echo "----------------------------------------------------------------------"
@@ -420,13 +403,6 @@ run-sql-integration-tests:
420403
@echo "----------------------------------------------------------------------"
421404
./mvnw verify -am --no-transfer-progress -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) $(REGISTRY_IMAGE) -Premote-sql -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress
422405

423-
.PHONY: run-sql-upgrade-tests ## Runs sql e2e tests
424-
run-sql-upgrade-tests:
425-
@echo "----------------------------------------------------------------------"
426-
@echo " Running Sql Integration Tests "
427-
@echo "----------------------------------------------------------------------"
428-
./mvnw verify -am --no-transfer-progress -Pintegration-tests -Psqlit $(REGISTRY_IMAGE) -Premote-sql -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress
429-
430406
.PHONY: run-sql-auth-tests ## Runs sql auth integration tests
431407
run-sql-auth-tests:
432408
@echo "----------------------------------------------------------------------"
@@ -441,14 +417,6 @@ run-sql-migration-integration-tests:
441417
@echo "----------------------------------------------------------------------"
442418
./mvnw verify -am --no-transfer-progress -Pintegration-tests -Pmigration -Premote-sql -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress
443419

444-
.PHONY: run-sql-multitenancy-integration-tests ## Runs multitenancy integration tests
445-
run-sql-multitenancy-integration-tests:
446-
@echo "----------------------------------------------------------------------"
447-
@echo " Running Multitenancy Integration Tests "
448-
@echo "----------------------------------------------------------------------"
449-
./mvnw verify -am --no-transfer-progress -Pintegration-tests -Pmultitenancy -Premote-sql -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress -DtrimStackTrace=false
450-
451-
452420
############################################# KafkaSql Integration Tests #########################################################################
453421

454422

@@ -459,12 +427,6 @@ run-kafkasql-integration-tests:
459427
@echo "----------------------------------------------------------------------"
460428
./mvnw verify -am --no-transfer-progress -Pintegration-tests -P$(INTEGRATION_TESTS_PROFILE) -Premote-kafka -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress
461429

462-
.PHONY: run-kafkasql-upgrade-tests ## Runs sql e2e tests
463-
run-kafkasql-upgrade-tests :
464-
@echo "----------------------------------------------------------------------"
465-
@echo " Running KafkaSql Upgrade Integration Tests "
466-
@echo "----------------------------------------------------------------------"
467-
./mvnw verify -am --no-transfer-progress -Pintegration-tests -Pkafkasqlit -Premote-kafka -pl integration-tests -Dmaven.javadoc.skip=true --no-transfer-progress
468430

469431
.PHONY: run-kafkasql-migration-integration-tests ## Runs kafkasql migration integration tests
470432
run-kafkasql-migration-integration-tests:
@@ -520,7 +482,7 @@ run-mssql-migration-integration-tests:
520482

521483

522484
.PHONY: integration-tests ## Runs all integration tests [SKIP_TESTS, BUILD_FLAGS]
523-
integration-tests: build-all run-ui-tests run-sql-integration-tests run-mssql-integration-tests run-mssql-clustered-integration-tests run-kafkasql-integration-tests run-multitenancy-integration-tests run-sql-migration-integration-tests run-mssql-migration-integration-tests run-kafkasql-migration-integration-tests run-sql-auth-integration-tests run-mssql-auth-integration-tests run-kafkasql-auth-integration-tests run-sql-legacy-tests run-mssql-legacy-tests run-kafkasql-legacy-tests
485+
integration-tests: build-all run-ui-tests run-sql-integration-tests run-mssql-integration-tests run-mssql-clustered-integration-tests run-kafkasql-integration-tests run-sql-migration-integration-tests run-mssql-migration-integration-tests run-kafkasql-migration-integration-tests run-sql-auth-integration-tests run-mssql-auth-integration-tests run-kafkasql-auth-integration-tests run-sql-legacy-tests run-mssql-legacy-tests run-kafkasql-legacy-tests
524486

525487
# Please declare your targets as .PHONY in the format shown below, so that the 'make help' parses the information correctly.
526488
#

TESTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ This set of tests are mainly designed to work in two different modes:
2828

2929
### ITs with local infrastructure
3030

31-
This is the normal mode used when you execute the testsuite. Because Apicurio Registry supports various storage backends and various deployment time configurations(such as multitenancy, authentication,...) this tests deploy different components depending on the test executed. This is achieved using Quarkus profiles. For example, when a multitenancy test is executed, a tenant-manager instance will be deployed.
31+
This is the normal mode used when you execute the testsuite. Because Apicurio Registry supports various storage backends and various deployment time configurations(such as authentication,...) this tests deploy different components depending on the test executed. This is achieved using Quarkus profiles.
3232

3333
When running from the terminal, the configuration is provided via maven profiles. You can find all the available maven profiles [here](integration-tests/pom.xml)
3434

3535
When executing the testsuite you normally provide two profiles:
36-
+ test profile (which determines the tests that will be executed), with the following options: all, ci, smoke, serdes, ui, acceptance, auth, multitenancy, migration, sqlit, kafkasqlit.
36+
+ test profile (which determines the tests that will be executed), with the following options: all, ci, smoke, serdes, ui, acceptance, auth, migration, sqlit, kafkasqlit.
3737
+ storage variant to test (which determines the storage backend that will be deployed, and therefore tested), the available options for running the test locally are: local-mem , local-sql, local-mssql , local-kafka.
3838

3939
As you might expect, this testsuite mode depends on the rest of the project to be built first, in order to have the application jars/images available or the serdes module to be available as well.

app/pom.xml

-12
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@
5959
<groupId>io.apicurio</groupId>
6060
<artifactId>apicurio-common-app-components-auth</artifactId>
6161
</dependency>
62-
63-
<dependency>
64-
<groupId>io.apicurio</groupId>
65-
<artifactId>apicurio-common-app-components-multitenancy</artifactId>
66-
</dependency>
67-
68-
<!-- Tenant Manager Client -->
69-
<dependency>
70-
<groupId>io.apicurio</groupId>
71-
<artifactId>apicurio-tenant-manager-client</artifactId>
72-
</dependency>
73-
7462
<dependency>
7563
<groupId>io.apicurio</groupId>
7664
<artifactId>apicurio-common-rest-client-jdk</artifactId>

app/src/main/java/io/apicurio/registry/auth/AdminOverride.java

-21
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package io.apicurio.registry.auth;
1818

19-
import io.apicurio.common.apps.multitenancy.MultitenancyProperties;
20-
import io.apicurio.common.apps.multitenancy.TenantContext;
2119
import io.quarkus.security.identity.SecurityIdentity;
2220
import jakarta.enterprise.context.ApplicationScoped;
2321
import jakarta.enterprise.inject.Instance;
@@ -41,18 +39,7 @@ public class AdminOverride {
4139
@Inject
4240
Instance<JsonWebToken> jsonWebToken;
4341

44-
@Inject
45-
TenantContext tenantContext;
46-
47-
@Inject
48-
MultitenancyProperties mtProperties;
49-
5042
public boolean isAdmin() {
51-
// When multi-tenancy is enabled, the owner of the tenant is always an admin.
52-
if (mtProperties.isMultitenancyEnabled() && authConfig.isTenantOwnerAdminEnabled() && isTenantOwner()) {
53-
return true;
54-
}
55-
5643
if (!authConfig.adminOverrideEnabled) {
5744
return false;
5845
}
@@ -67,14 +54,6 @@ public boolean isAdmin() {
6754
return false;
6855
}
6956

70-
private boolean isTenantOwner() {
71-
String tOwner = tenantContext.tenantOwner();
72-
return tOwner != null &&
73-
securityIdentity != null &&
74-
securityIdentity.getPrincipal() != null &&
75-
tOwner.equals(securityIdentity.getPrincipal().getName());
76-
}
77-
7857
private boolean hasAdminRole() {
7958
return securityIdentity.hasRole(authConfig.adminOverrideRole);
8059
}

app/src/main/java/io/apicurio/registry/auth/AuthConfig.java

-9
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ public class AuthConfig {
8585
@Info(category = "auth", description = "Auth roles source", availableSince = "2.1.0.Final")
8686
String roleSource;
8787

88-
@ConfigProperty(name = "registry.auth.tenant-owner-is-admin.enabled", defaultValue = "true")
89-
@Info(category = "auth", description = "Auth tenant owner admin enabled", availableSince = "2.1.0.Final")
90-
boolean tenantOwnerIsAdminEnabled;
91-
9288
@ConfigProperty(name = "registry.auth.admin-override.enabled", defaultValue = "false")
9389
@Info(category = "auth", description = "Auth admin override enabled", availableSince = "2.1.0.Final")
9490
boolean adminOverrideEnabled;
@@ -125,7 +121,6 @@ void onConstruct() {
125121
log.debug(" Role Source: " + roleSource);
126122
}
127123
log.debug("OBAC Enabled: " + ownerOnlyAuthorizationEnabled);
128-
log.debug("Tenant Owner is Admin: " + tenantOwnerIsAdminEnabled);
129124
log.debug("Admin Override Enabled: " + adminOverrideEnabled);
130125
if (adminOverrideEnabled) {
131126
log.debug(" Admin Override from: " + adminOverrideFrom);
@@ -149,10 +144,6 @@ public boolean isObacEnabled() {
149144
return this.ownerOnlyAuthorizationEnabled.get();
150145
}
151146

152-
public boolean isTenantOwnerAdminEnabled() {
153-
return this.tenantOwnerIsAdminEnabled;
154-
}
155-
156147
public boolean isAdminOverrideEnabled() {
157148
return this.adminOverrideEnabled;
158149
}

app/src/main/java/io/apicurio/registry/auth/AuthorizedInterceptor.java

+1-69
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
package io.apicurio.registry.auth;
1818

19-
import io.apicurio.common.apps.config.Info;
20-
import io.apicurio.common.apps.multitenancy.ApicurioTenantContext;
21-
import io.apicurio.common.apps.multitenancy.MultitenancyProperties;
22-
import io.apicurio.common.apps.multitenancy.TenantContext;
23-
import io.apicurio.common.apps.multitenancy.exceptions.TenantNotAuthorizedException;
2419
import io.quarkus.security.ForbiddenException;
2520
import io.quarkus.security.UnauthorizedException;
2621
import io.quarkus.security.identity.SecurityIdentity;
@@ -30,18 +25,13 @@
3025
import jakarta.interceptor.AroundInvoke;
3126
import jakarta.interceptor.Interceptor;
3227
import jakarta.interceptor.InvocationContext;
33-
import org.eclipse.microprofile.config.inject.ConfigProperty;
3428
import org.eclipse.microprofile.jwt.JsonWebToken;
3529
import org.slf4j.Logger;
3630

37-
import java.util.List;
38-
import java.util.Optional;
39-
4031
/**
4132
* This class implements authorization logic for the registry. It is driven by a combination of the
4233
* security identity (authenticated user) and configured security level of the operation the user is
43-
* attempting to perform. In a multitenant deployment, this authorization interceptor also checks if
44-
* the user accessing the tenant has the proper permission level. This interceptor will be triggered
34+
* attempting to perform. This interceptor will be triggered
4535
* for any method that is annotated with the {@link Authorized} annotation. Please ensure that all
4636
* JAX-RS operations are propertly annotated.
4737
*
@@ -73,35 +63,9 @@ public class AuthorizedInterceptor {
7363
@Inject
7464
OwnerBasedAccessController obac;
7565

76-
@Inject
77-
MultitenancyProperties mtProperties;
78-
79-
@Inject
80-
TenantContext tenantContext;
81-
82-
@ConfigProperty(name = "registry.organization-id.claim-name")
83-
@Info(category = "mt", description = "Organization ID claim name", availableSince = "2.1.0.Final")
84-
List<String> organizationIdClaims;
85-
8666
@AroundInvoke
8767
public Object authorizeMethod(InvocationContext context) throws Exception {
8868

89-
//execute multitenancy related authorization checks
90-
if (mtProperties.isMultitenancyEnabled()) {
91-
92-
//if multitenancy is enabled but no tenant context is loaded, because no tenant was resolved from request, reject it
93-
//this is to avoid access to default tenant "_" when multitenancy is enabled
94-
if (!tenantContext.isLoaded()) {
95-
log.warn("Request is rejected because the tenant could not be found, and access to default tenant is disabled in a multitenant deployment");
96-
throw new ForbiddenException("Default tenant access is not allowed in multitenancy mode.");
97-
}
98-
99-
//If multitenancy authorization is enabled, check tenant access.
100-
if (mtProperties.isMultitenancyAuthorizationEnabled()) {
101-
checkTenantAuthorization(tenantContext.currentContext());
102-
}
103-
}
104-
10569
// If the user is trying to invoke a role-mapping operation, deny it if
10670
// database based RBAC is not enabled.
10771
RoleBasedAccessApiOperation rbacOpAnnotation = context.getMethod().getAnnotation(RoleBasedAccessApiOperation.class);
@@ -174,36 +138,4 @@ public Object authorizeMethod(InvocationContext context) throws Exception {
174138

175139
return context.proceed();
176140
}
177-
178-
private void checkTenantAuthorization(ApicurioTenantContext tenant) {
179-
if (authConfig.isAuthEnabled()) {
180-
if (!isTokenResolvable()) {
181-
log.debug("Tenant access attempted without JWT token for tenant {} [allowing because some endpoints allow anonymous access]", tenant.getTenantId());
182-
return;
183-
}
184-
String accessedOrganizationId = null;
185-
186-
for (String organizationIdClaim : organizationIdClaims) {
187-
final Optional<Object> claimValue = jsonWebToken.get().claim(organizationIdClaim);
188-
if (claimValue.isPresent()) {
189-
accessedOrganizationId = (String) claimValue.get();
190-
break;
191-
}
192-
}
193-
194-
if (null == accessedOrganizationId || !tenantCanAccessOrganization(tenant, accessedOrganizationId)) {
195-
log.warn("User not authorized to access tenant.");
196-
throw new TenantNotAuthorizedException("Tenant not authorized");
197-
}
198-
}
199-
}
200-
201-
private boolean isTokenResolvable() {
202-
return jsonWebToken.isResolvable() && jsonWebToken.get().getRawToken() != null;
203-
}
204-
205-
private boolean tenantCanAccessOrganization(ApicurioTenantContext tenant, String accessedOrganizationId) {
206-
return tenant == null || accessedOrganizationId.equals(tenant.getOrganizationId());
207-
}
208-
209141
}

0 commit comments

Comments
 (0)