forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for azure keyvault and tomcat filters
- Loading branch information
1 parent
21f3e32
commit 005c5ab
Showing
11 changed files
with
178 additions
and
538 deletions.
There are no files selected for viewing
591 changes: 63 additions & 528 deletions
591
...figuration/src/main/java/org/apereo/cas/configuration/model/core/CasServerProperties.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
core/cas-server-core-configuration-cloud-azure-keyvault/build.gradle
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,5 @@ | ||
description = "Apereo CAS Core Configuration - Microsoft Azure KeyVault" | ||
dependencies { | ||
implementation libraries.azurekeyvault | ||
implementation project(":core:cas-server-core-util-api") | ||
} |
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
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
59 changes: 59 additions & 0 deletions
59
...t/src/main/java/org/apereo/cas/config/CasEmbeddedContainerTomcatFiltersConfiguration.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,59 @@ | ||
package org.apereo.cas.config; | ||
|
||
import org.apache.catalina.filters.CsrfPreventionFilter; | ||
import org.apache.catalina.filters.RemoteAddrFilter; | ||
import org.apereo.cas.CasEmbeddedContainerUtils; | ||
import org.apereo.cas.configuration.CasConfigurationProperties; | ||
import org.apereo.cas.configuration.model.core.web.tomcat.CasEmbeddedApacheTomcatRemoteAddressProperties; | ||
import org.apereo.cas.util.CollectionUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.cloud.context.config.annotation.RefreshScope; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpStatus; | ||
|
||
/** | ||
* This is {@link CasEmbeddedContainerTomcatFiltersConfiguration}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 5.0.0 | ||
*/ | ||
@Configuration("casEmbeddedContainerTomcatFiltersConfiguration") | ||
@EnableConfigurationProperties(CasConfigurationProperties.class) | ||
@ConditionalOnProperty(name = CasEmbeddedContainerUtils.EMBEDDED_CONTAINER_CONFIG_ACTIVE, havingValue = "true") | ||
@ImportAutoConfiguration(CasEmbeddedContainerTomcatConfiguration.class) | ||
public class CasEmbeddedContainerTomcatFiltersConfiguration { | ||
@Autowired | ||
private CasConfigurationProperties casProperties; | ||
|
||
@ConditionalOnProperty(prefix = "cas.server.csrf", name = "enabled", havingValue = "true") | ||
@RefreshScope | ||
@Bean | ||
public FilterRegistrationBean tomcatCsrfPreventionFilter() { | ||
final FilterRegistrationBean bean = new FilterRegistrationBean(); | ||
bean.setFilter(new CsrfPreventionFilter()); | ||
bean.setUrlPatterns(CollectionUtils.wrap("/*")); | ||
bean.setName("tomcatCsrfPreventionFilter"); | ||
return bean; | ||
} | ||
|
||
@ConditionalOnProperty(prefix = "cas.server.remoteAddr", name = "enabled", havingValue = "true") | ||
@RefreshScope | ||
@Bean | ||
public FilterRegistrationBean tomcatRemoteAddressFilter() { | ||
final FilterRegistrationBean bean = new FilterRegistrationBean(); | ||
final CasEmbeddedApacheTomcatRemoteAddressProperties addr = casProperties.getServer().getRemoteAddr(); | ||
final RemoteAddrFilter filter = new RemoteAddrFilter(); | ||
filter.setAllow(addr.getAllowedClientIpAddressRegex()); | ||
filter.setDeny(addr.getDeniedClientIpAddressRegex()); | ||
filter.setDenyStatus(HttpStatus.UNAUTHORIZED.value()); | ||
bean.setFilter(filter); | ||
bean.setUrlPatterns(CollectionUtils.wrap("/*")); | ||
bean.setName("tomcatRemoteAddressFilter"); | ||
return bean; | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
webapp/cas-server-webapp-tomcat/src/main/resources/META-INF/spring.factories
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration | ||
org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration,\ | ||
org.apereo.cas.config.CasEmbeddedContainerTomcatFiltersConfiguration | ||
|