-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid exceptions when gateway-shared-auth is disabled after being ena…
…bled If the `gateway-shared-auth` geoserver authentication filter was enabled, and it was automatically added to the filter chains, when disabled and the applications restart, would produce an error message and the webui Authentication configuration page would be broken. This patch adds a no-op filter when `gateway-shared-auth` is disabled by externalized configuration.
- Loading branch information
Showing
13 changed files
with
170 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...java/org/geoserver/cloud/autoconfigure/authzn/ConditionalOnGatewaySharedAuthDisabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.autoconfigure.authzn; | ||
|
||
import org.geoserver.cloud.autoconfigure.security.ConditionalOnGeoServerSecurityEnabled; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** Conditional to check if gateway/webui shared authentication is disabled. */ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
@Documented | ||
@ConditionalOnGeoServerSecurityEnabled | ||
@ConditionalOnProperty( | ||
name = GatewaySharedAuthConfigProperties.ENABLED_PROP, | ||
havingValue = "false", | ||
matchIfMissing = true) | ||
public @interface ConditionalOnGatewaySharedAuthDisabled {} |
29 changes: 29 additions & 0 deletions
29
.../java/org/geoserver/cloud/autoconfigure/authzn/ConditionalOnGatewaySharedAuthEnabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.autoconfigure.authzn; | ||
|
||
import org.geoserver.cloud.autoconfigure.security.ConditionalOnGeoServerSecurityEnabled; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Conditional to enable gateway/webui shared authentication mechanism. It must also be enabled in | ||
* the gateway with the same config property {@code | ||
* geoserver.security.gateway-shared-auth.enabled=true} | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
@Documented | ||
@ConditionalOnGeoServerSecurityEnabled | ||
@ConditionalOnProperty( | ||
name = GatewaySharedAuthConfigProperties.ENABLED_PROP, | ||
havingValue = "true", | ||
matchIfMissing = false) | ||
public @interface ConditionalOnGatewaySharedAuthEnabled {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../src/main/java/org/geoserver/cloud/security/gateway/sharedauth/DisabledConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* (c) 2024 Open Source Geospatial Foundation - all rights reserved This code is licensed under the | ||
* GPL 2.0 license, available at the root application directory. | ||
*/ | ||
package org.geoserver.cloud.security.gateway.sharedauth; | ||
|
||
import static org.geoserver.cloud.security.gateway.sharedauth.GatewaySharedAuthenticationProvider.Mode.DISABLED; | ||
|
||
import org.geoserver.security.filter.AbstractFilterProvider; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Contributes a {@link GatewaySharedAuthenticationProvider} in disabled mode, essentially a no-op | ||
* {@link AbstractFilterProvider} to avoid starup failure when the gateway shared auth was enabled, | ||
* then disabled, and geoserver restarted. | ||
* | ||
* @see ClientConfiguration | ||
* @see ServerConfiguration | ||
* @since 1.9 | ||
*/ | ||
@Configuration | ||
public class DisabledConfiguration { | ||
|
||
@Bean | ||
GatewaySharedAuthenticationProvider gatewaySharedAuthenticationProvider() { | ||
return new GatewaySharedAuthenticationProvider(DISABLED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters