support schema per tenant multi-tenancy. basic auth security filter is extended to detect tenant-id header on request, verify tenant id is valid and then use provided credentials to authenticate user details against users on the tenant specific schema.

This commit is contained in:
Keith Woodlock
2012-07-13 18:05:43 +01:00
parent 816d3decf9
commit 15f0fc4677
34 changed files with 399 additions and 195 deletions
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<ResourceLink name="jdbc/mifosng" global="jdbc/mifosng" type="javax.sql.DataSource" />
<ResourceLink name="jdbc/mifosplatform-tenants" global="jdbc/mifosplatform-tenants" type="javax.sql.DataSource" />
</Context>
@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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:mvc="http://www.springframework.org/schema/mvc"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- The controllers are autodetected POJOs labeled with the @Controller annotation. -->
<context:component-scan base-package="org.mifosng.platform.security, org.mifosng.platform.infrastructure" use-default-filters="false">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean id="mvcConversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<!-- Turns on support for mapping requests to Spring MVC @Controller methods (DefaultAnnotationHandler is added to list of handlers)
Also registers default Formatters and Validators for use across all @Controllers -->
<mvc:annotation-driven conversion-service="mvcConversionService"/>
<mvc:default-servlet-handler />
<mvc:resources location="/WEB-INF/static/" mapping="/resources/**" cache-period="31556926"/>
<mvc:view-controller path="/index" view-name="index"/>
<mvc:view-controller path="/home" view-name="home"/>
<mvc:view-controller path="/login" view-name="login"/>
<mvc:view-controller path="/logout" view-name="logout"/>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
@@ -5,12 +5,12 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="mifosng-platform-provider" version="2.5">
<display-name>MifosNg - Platform</display-name>
<display-name>Mifos Platform</display-name>
<description>A provider of microfinance services which applications can consume once authenticated and authorized.</description>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>mifosngserver.root</param-value>
<param-value>mifosplatform.root</param-value>
</context-param>
<context-param>
@@ -28,26 +28,10 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
<filter>
<filter-name>filterChainProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>filterChainProxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
@@ -77,30 +61,4 @@
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/api/v1/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/webmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>