Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Basic Auth for testing purposes #4632

Merged
merged 21 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ jobs:
build-verify-python-sdk:
name: Verify Python SDK
runs-on: ubuntu-latest
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
steps:
- name: Checkout Code with Ref '${{ github.ref }}'
uses: actions/checkout@v3
Expand Down Expand Up @@ -343,7 +343,7 @@ jobs:
build-verify-go-sdk:
name: Verify Go SDK
runs-on: ubuntu-latest
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
steps:
- name: Checkout Code with Ref '${{ github.ref }}'
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ python-sdk/apicurioregistrysdk/client
python-sdk/openapi.json
__pycache__


.env
23 changes: 19 additions & 4 deletions app/src/main/java/io/apicurio/registry/auth/AuthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ public class AuthConfig {
Logger log;

@ConfigProperty(name = "quarkus.oidc.tenant-enabled", defaultValue = "false")
boolean authenticationEnabled;
@Info(category = "auth", description = "Enable auth", availableSince = "0.1.18-SNAPSHOT", registryAvailableSince = "2.0.0.Final", studioAvailableSince = "1.0.0")
boolean oidcAuthEnabled;

@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")
@ConfigProperty(name = "apicurio.authn.basic-client-credentials.enabled", defaultValue = "false")
@Info(category = "auth", description = "Enable basic auth client credentials", availableSince = "0.1.18-SNAPSHOT", registryAvailableSince = "2.1.0.Final", studioAvailableSince = "1.0.0")
Supplier<Boolean> basicClientCredentialsAuthEnabled;

@ConfigProperty(name = "quarkus.http.auth.basic", defaultValue = "false")
@Info(category = "auth", description = "Enable basic auth", availableSince = "1.1.X-SNAPSHOT", registryAvailableSince = "3.X.X.Final", studioAvailableSince = "1.0.0")
boolean basicAuthEnabled;

@ConfigProperty(name = "apicurio.auth.role-based-authorization", defaultValue = "false")
@Info(category = "auth", description = "Enable role based authorization", availableSince = "2.1.0.Final")
Expand Down Expand Up @@ -97,7 +107,8 @@ public class AuthConfig {
@PostConstruct
void onConstruct() {
log.debug("===============================");
log.debug("Auth Enabled: " + authenticationEnabled);
log.debug("OIDC Auth Enabled: " + oidcAuthEnabled);
log.debug("Basic Auth Enabled: " + basicAuthEnabled);
log.debug("Anonymous Read Access Enabled: " + anonymousReadAccessEnabled);
log.debug("Authenticated Read Access Enabled: " + authenticatedReadAccessEnabled);
log.debug("RBAC Enabled: " + roleBasedAuthorizationEnabled);
Expand All @@ -117,8 +128,12 @@ void onConstruct() {
log.debug("===============================");
}

public boolean isAuthEnabled() {
return this.authenticationEnabled;
public boolean isOidcAuthEnabled() {
return this.oidcAuthEnabled;
}

public boolean isBasicAuthEnabled() {
return this.basicAuthEnabled;
}

public boolean isRbacEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object authorizeMethod(InvocationContext context) throws Exception {
}

// If authentication is not enabled, just do it.
if (!authConfig.authenticationEnabled) {
if (!authConfig.oidcAuthEnabled && !authConfig.basicAuthEnabled) {
return context.proceed();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ private UserInterfaceConfigAuth uiAuthConfig() {
UserInterfaceConfigAuth rval = new UserInterfaceConfigAuth();
rval.setObacEnabled(authConfig.isObacEnabled());
rval.setRbacEnabled(authConfig.isRbacEnabled());
rval.setType(authConfig.isAuthEnabled() ? UserInterfaceConfigAuth.Type.oidc : UserInterfaceConfigAuth.Type.none);
if (authConfig.isAuthEnabled()) {
rval.setType(authConfig.isOidcAuthEnabled() ? UserInterfaceConfigAuth.Type.oidc :
authConfig.isBasicAuthEnabled() ? UserInterfaceConfigAuth.Type.basic : UserInterfaceConfigAuth.Type.none);
if (authConfig.isOidcAuthEnabled()) {
Map<String, String> options = new HashMap<>();
options.put("url", uiConfig.authOidcUrl);
options.put("redirectUri", uiConfig.authOidcRedirectUri);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ quarkus.oidc.token-path=https://auth.apicur.io/auth/realms/apicurio-local/protoc
quarkus.oidc.client-id=registry-api
quarkus.http.auth.proactive=false

# Build time property to enable username and password SecurityIdentity
quarkus.security.users.embedded.enabled=true

# HTTP
quarkus.http.port=8080
quarkus.http.non-application-root-path=/
Expand Down