Skip to content

Commit 11b7e71

Browse files
andreaTPAndrea Peruffo
and
Andrea Peruffo
authoredMay 16, 2024
Enable Basic Auth for testing purposes (#4632)
* WIP Basic Auth in Registry * more and test in ci * remove env * fix docs for now * tests * more * fixes * comment failing test * fix the test * wip UI integration of basic auth * ui implementation of basic auth * last working setup * cleanup * fixes * review * bump common-app-components * finalize * update deps * more * fix pom --------- Co-authored-by: Andrea Peruffo <aperuffo@aperuffo-thinkpadp1gen4i.remote.csb>
1 parent c4b5bd5 commit 11b7e71

File tree

21 files changed

+641
-107
lines changed

21 files changed

+641
-107
lines changed
 

‎.github/workflows/verify.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ jobs:
306306
build-verify-python-sdk:
307307
name: Verify Python SDK
308308
runs-on: ubuntu-latest
309-
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
309+
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
310310
steps:
311311
- name: Checkout Code with Ref '${{ github.ref }}'
312312
uses: actions/checkout@v3
@@ -343,7 +343,7 @@ jobs:
343343
build-verify-go-sdk:
344344
name: Verify Go SDK
345345
runs-on: ubuntu-latest
346-
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
346+
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
347347
steps:
348348
- name: Checkout Code with Ref '${{ github.ref }}'
349349
uses: actions/checkout@v3

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ python-sdk/apicurioregistrysdk/client
3232
python-sdk/openapi.json
3333
__pycache__
3434

35-
35+
.env

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ public class AuthConfig {
1818
Logger log;
1919

2020
@ConfigProperty(name = "quarkus.oidc.tenant-enabled", defaultValue = "false")
21-
boolean authenticationEnabled;
21+
@Info(category = "auth", description = "Enable auth", availableSince = "0.1.18-SNAPSHOT", registryAvailableSince = "2.0.0.Final", studioAvailableSince = "1.0.0")
22+
boolean oidcAuthEnabled;
23+
24+
@Dynamic(label = "HTTP basic authentication", description = "When selected, users are permitted to authenticate using HTTP basic authentication (in addition to OAuth).", requires = "apicurio.authn.enabled=true")
25+
@ConfigProperty(name = "apicurio.authn.basic-client-credentials.enabled", defaultValue = "false")
26+
@Info(category = "auth", description = "Enable basic auth client credentials", availableSince = "0.1.18-SNAPSHOT", registryAvailableSince = "2.1.0.Final", studioAvailableSince = "1.0.0")
27+
Supplier<Boolean> basicClientCredentialsAuthEnabled;
28+
29+
@ConfigProperty(name = "quarkus.http.auth.basic", defaultValue = "false")
30+
@Info(category = "auth", description = "Enable basic auth", availableSince = "1.1.X-SNAPSHOT", registryAvailableSince = "3.X.X.Final", studioAvailableSince = "1.0.0")
31+
boolean basicAuthEnabled;
2232

2333
@ConfigProperty(name = "apicurio.auth.role-based-authorization", defaultValue = "false")
2434
@Info(category = "auth", description = "Enable role based authorization", availableSince = "2.1.0.Final")
@@ -97,7 +107,8 @@ public class AuthConfig {
97107
@PostConstruct
98108
void onConstruct() {
99109
log.debug("===============================");
100-
log.debug("Auth Enabled: " + authenticationEnabled);
110+
log.debug("OIDC Auth Enabled: " + oidcAuthEnabled);
111+
log.debug("Basic Auth Enabled: " + basicAuthEnabled);
101112
log.debug("Anonymous Read Access Enabled: " + anonymousReadAccessEnabled);
102113
log.debug("Authenticated Read Access Enabled: " + authenticatedReadAccessEnabled);
103114
log.debug("RBAC Enabled: " + roleBasedAuthorizationEnabled);
@@ -117,8 +128,12 @@ void onConstruct() {
117128
log.debug("===============================");
118129
}
119130

120-
public boolean isAuthEnabled() {
121-
return this.authenticationEnabled;
131+
public boolean isOidcAuthEnabled() {
132+
return this.oidcAuthEnabled;
133+
}
134+
135+
public boolean isBasicAuthEnabled() {
136+
return this.basicAuthEnabled;
122137
}
123138

124139
public boolean isRbacEnabled() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Object authorizeMethod(InvocationContext context) throws Exception {
6060
}
6161

6262
// If authentication is not enabled, just do it.
63-
if (!authConfig.authenticationEnabled) {
63+
if (!authConfig.oidcAuthEnabled && !authConfig.basicAuthEnabled) {
6464
return context.proceed();
6565
}
6666

‎app/src/main/java/io/apicurio/registry/rest/v3/SystemResourceImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ private UserInterfaceConfigAuth uiAuthConfig() {
103103
UserInterfaceConfigAuth rval = new UserInterfaceConfigAuth();
104104
rval.setObacEnabled(authConfig.isObacEnabled());
105105
rval.setRbacEnabled(authConfig.isRbacEnabled());
106-
rval.setType(authConfig.isAuthEnabled() ? UserInterfaceConfigAuth.Type.oidc : UserInterfaceConfigAuth.Type.none);
107-
if (authConfig.isAuthEnabled()) {
106+
rval.setType(authConfig.isOidcAuthEnabled() ? UserInterfaceConfigAuth.Type.oidc :
107+
authConfig.isBasicAuthEnabled() ? UserInterfaceConfigAuth.Type.basic : UserInterfaceConfigAuth.Type.none);
108+
if (authConfig.isOidcAuthEnabled()) {
108109
Map<String, String> options = new HashMap<>();
109110
options.put("url", uiConfig.authOidcUrl);
110111
options.put("redirectUri", uiConfig.authOidcRedirectUri);

‎app/src/main/resources/application.properties

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ quarkus.oidc.token-path=https://auth.apicur.io/auth/realms/apicurio-local/protoc
88
quarkus.oidc.client-id=registry-api
99
quarkus.http.auth.proactive=false
1010

11+
# Build time property to enable username and password SecurityIdentity
12+
quarkus.security.users.embedded.enabled=true
13+
1114
# HTTP
1215
quarkus.http.port=8080
1316
quarkus.http.non-application-root-path=/

0 commit comments

Comments
 (0)