FINERACT-1433: Switch to Java based config for Spring
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
2513ee4837
commit
2b57bf379e
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:sec="http://www.springframework.org/schema/security"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
|
||||
<sec:global-method-security
|
||||
pre-post-annotations="enabled" />
|
||||
|
||||
<context:component-scan base-package="org.apache.fineract.**">
|
||||
<context:exclude-filter expression="org.springframework.stereotype.Controller"
|
||||
type="annotation" />
|
||||
|
||||
<!-- We do NOT want all @Configuration "beans" to be auto-detected by ComponentScan,
|
||||
but we want to use / import them explicitly in Tests & Spring Boot applications,
|
||||
or other import in other @Configuration, so that we could have mutually exclusive ones.
|
||||
-->
|
||||
<context:exclude-filter expression="org.springframework.context.annotation.Configuration"
|
||||
type="annotation" />
|
||||
</context:component-scan>
|
||||
|
||||
<bean id="auditorAware"
|
||||
class="org.apache.fineract.infrastructure.core.domain.AuditorAwareImpl" />
|
||||
<jpa:auditing auditor-aware-ref="auditorAware" />
|
||||
<jpa:repositories base-package="org.apache.fineract.**.domain" />
|
||||
|
||||
<import resource="infrastructure.xml" />
|
||||
|
||||
<import resource="securityContext.xml" />
|
||||
|
||||
<import resource="cache.xml" />
|
||||
|
||||
<bean id="applicationEventMulticaster" class="org.springframework.context.event.SimpleApplicationEventMulticaster">
|
||||
<property name="taskExecutor">
|
||||
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- The application events (for importing) rely on the inheritable thread local security context strategy
|
||||
This is NOT compatible with threadpools so if we use threadpools the below will need to be reworked -->
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetClass"
|
||||
value="org.springframework.security.core.context.SecurityContextHolder" />
|
||||
<property name="targetMethod" value="setStrategyName" />
|
||||
<property name="arguments" value="MODE_INHERITABLETHREADLOCAL" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
|
||||
<bean id="ehcacheManager" class="org.springframework.cache.jcache.JCacheCacheManager"
|
||||
p:cacheManager-ref="ehcacheInstance" />
|
||||
|
||||
<bean id="ehcacheInstance"
|
||||
class="org.springframework.cache.jcache.JCacheManagerFactoryBean" p:cacheManagerUri="classpath:/META-INF/spring/ehcache.xml"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.ehcache.org/v3'
|
||||
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.7.xsd">
|
||||
|
||||
<cache-template name="defaultTemplate">
|
||||
<expiry>
|
||||
<none/>
|
||||
</expiry>
|
||||
<heap unit="entries">
|
||||
10000
|
||||
</heap>
|
||||
</cache-template>
|
||||
|
||||
<cache alias="users" uses-template="defaultTemplate"/>
|
||||
<cache alias="usersByUsername" uses-template="defaultTemplate"/>
|
||||
<cache alias="tenantsById" uses-template="defaultTemplate"/>
|
||||
<cache alias="offices" uses-template="defaultTemplate"/>
|
||||
<cache alias="officesForDropdown" uses-template="defaultTemplate"/>
|
||||
<cache alias="officesById" uses-template="defaultTemplate"/>
|
||||
<cache alias="charges" uses-template="defaultTemplate"/>
|
||||
<cache alias="funds" uses-template="defaultTemplate"/>
|
||||
<cache alias="code_values" uses-template="defaultTemplate"/>
|
||||
<cache alias="codes" uses-template="defaultTemplate"/>
|
||||
<cache alias="hooks" uses-template="defaultTemplate"/>
|
||||
<cache alias="tfConfig" uses-template="defaultTemplate"/>
|
||||
<cache alias="userTFAccessToken" uses-template="defaultTemplate">
|
||||
<expiry>
|
||||
<tti unit="seconds">7200</tti>
|
||||
</expiry>
|
||||
</cache>
|
||||
</config>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
|
||||
|
||||
<!-- HikariCP Database bean -->
|
||||
<bean id="hikariTenantDataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
|
||||
<constructor-arg ref="hikariConfig" />
|
||||
</bean>
|
||||
|
||||
<!-- HikariConfig config that is fed to above dataSource -->
|
||||
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
|
||||
<property name="driverClassName" value="${fineract_tenants_driver}" />
|
||||
<property name="jdbcUrl" value="${fineract_tenants_url}" />
|
||||
<property name="username" value="${fineract_tenants_uid}" />
|
||||
<property name="password" value="${fineract_tenants_pwd}" />
|
||||
<property name="minimumIdle" value="3" />
|
||||
<property name="maximumPoolSize" value="10" />
|
||||
<property name="idleTimeout" value="60000" />
|
||||
<property name="ConnectionTestQuery" value="SELECT 1" />
|
||||
|
||||
<!-- These are the properties for the all Tenants DB; the same configuration is also (hard-coded) in the TomcatJdbcDataSourcePerTenantService class -->
|
||||
<property name="dataSourceProperties">
|
||||
<props>
|
||||
<!-- https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration -->
|
||||
<prop key="cachePrepStmts">true</prop>
|
||||
<prop key="prepStmtCacheSize">250</prop>
|
||||
<prop key="prepStmtCacheSqlLimit">2048</prop>
|
||||
<prop key="useServerPrepStmts">true</prop>
|
||||
<prop key="useLocalSessionState">true</prop>
|
||||
<prop key="rewriteBatchedStatements">true</prop>
|
||||
<prop key="cacheResultSetMetadata">true</prop>
|
||||
<prop key="cacheServerConfiguration">true</prop>
|
||||
<prop key="elideSetAutoCommits">true</prop>
|
||||
<prop key="maintainTimeStats">false</prop>
|
||||
|
||||
<!-- https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj -->
|
||||
<!-- TODO FINERACT-890: <prop key="logger">com.mysql.cj.log.Slf4JLogger</prop> -->
|
||||
<prop key="logSlowQueries">true</prop>
|
||||
<prop key="dumpQueriesOnException">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
|
||||
|
||||
<bean id="entityManagerFactory"
|
||||
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||
depends-on="tenantDatabaseUpgradeService">
|
||||
<property name="dataSource" ref="routingDataSource" />
|
||||
<property name="persistenceUnitName" value="jpa-pu" />
|
||||
<property name="jpaVendorAdapter">
|
||||
<bean class="org.apache.fineract.infrastructure.openjpa.OpenJpaVendorAdapter"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Create instance of transaction template for programmatic transaction manipulation -->
|
||||
<bean id="txTemplate" class="org.springframework.transaction.support.TransactionTemplate">
|
||||
<property name="transactionManager" ref="transactionManager"></property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -31,60 +31,6 @@
|
||||
http://www.springframework.org/schema/security
|
||||
https://www.springframework.org/schema/security/spring-security.xsd">
|
||||
|
||||
<beans:beans profile="basicauth">
|
||||
<http create-session="stateless" use-expressions="true" pattern="/api/**"
|
||||
entry-point-ref="basicAuthenticationEntryPoint">
|
||||
<csrf disabled="true"/>
|
||||
<intercept-url pattern="/api/*/echo" access="permitAll" />
|
||||
<intercept-url pattern="/api/*/authentication" access="permitAll"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/self/authentication" access="permitAll"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/self/registration" access="permitAll"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/self/registration/user" access="permitAll"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/twofactor" access="isFullyAuthenticated()"
|
||||
method="GET" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/twofactor" access="isFullyAuthenticated()"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/*/twofactor/validate" access="isFullyAuthenticated()"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/**" access="isFullyAuthenticated() and hasAuthority('TWOFACTOR_AUTHENTICATED')"
|
||||
method="GET" requires-channel="https" />
|
||||
<intercept-url pattern="/api/**" access="isFullyAuthenticated() and hasAuthority('TWOFACTOR_AUTHENTICATED')"
|
||||
method="POST" requires-channel="https" />
|
||||
<intercept-url pattern="/api/**" access="isFullyAuthenticated() and hasAuthority('TWOFACTOR_AUTHENTICATED')"
|
||||
method="PUT" requires-channel="https" />
|
||||
<intercept-url pattern="/api/**" access="isFullyAuthenticated() and hasAuthority('TWOFACTOR_AUTHENTICATED')"
|
||||
method="DELETE" requires-channel="https" />
|
||||
<intercept-url pattern="/api/**" access="isFullyAuthenticated() and hasAuthority('TWOFACTOR_AUTHENTICATED')"
|
||||
method="HEAD" requires-channel="https" />
|
||||
|
||||
<custom-filter after="SECURITY_CONTEXT_FILTER" ref="basicAuthenticationProcessingFilter" />
|
||||
<custom-filter ref="twoFactorAuthFilter" after="BASIC_AUTH_FILTER" />
|
||||
</http>
|
||||
|
||||
<beans:bean id="basicAuthenticationEntryPoint"
|
||||
class="org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint">
|
||||
<beans:property name="realmName" value="Fineract Platform API" />
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="passwordEncoder" class="org.springframework.security.crypto.factory.PasswordEncoderFactories"
|
||||
factory-method="createDelegatingPasswordEncoder">
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="customAuthenticationProvider"
|
||||
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
|
||||
<beans:property name="userDetailsService" ref="userDetailsService" />
|
||||
<beans:property name="passwordEncoder" ref="passwordEncoder" />
|
||||
</beans:bean>
|
||||
|
||||
<authentication-manager alias="authenticationManager"
|
||||
erase-credentials="false">
|
||||
<authentication-provider ref="customAuthenticationProvider" />
|
||||
</authentication-manager>
|
||||
</beans:beans>
|
||||
<beans:beans profile="oauth">
|
||||
<http create-session="stateless" use-expressions="true" pattern="/api/v1/**"
|
||||
entry-point-ref="oauthAuthenticationEntryPoint"
|
||||
@@ -133,10 +79,6 @@
|
||||
<access-denied-handler ref="oauthAccessDeniedHandler" />
|
||||
</http>
|
||||
|
||||
<beans:bean id="passwordEncoder" class="org.springframework.security.crypto.factory.PasswordEncoderFactories"
|
||||
factory-method="createDelegatingPasswordEncoder">
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="oauthAuthenticationEntryPoint"
|
||||
class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
|
||||
<beans:property name="realmName" value="Fineract Platform API" />
|
||||
@@ -178,12 +120,6 @@
|
||||
<beans:constructor-arg ref="clientDetailsService" />
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="customAuthenticationProvider"
|
||||
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
|
||||
<beans:property name="userDetailsService" ref="userDetailsService" />
|
||||
<beans:property name="passwordEncoder" ref="passwordEncoder" />
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="clientDetailsService"
|
||||
class="org.springframework.security.oauth2.provider.client.JdbcClientDetailsService">
|
||||
<beans:constructor-arg ref="routingDataSource" />
|
||||
|
||||
Reference in New Issue
Block a user