forked from OhadR/Authentication-Flows-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spring-servlet.xml
171 lines (121 loc) · 6.57 KB
/
spring-servlet.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<context:property-placeholder location="classpath:/client.properties" />
<context:component-scan base-package="com.ohadr.security.oauth.examples" />
<context:component-scan base-package="com.ohadr.auth_flows.*" />
<context:component-scan base-package="com.ohadr.crypto.*" />
<context:annotation-config />
<mvc:default-servlet-handler />
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<sec:http pattern="/login/**" security="none" />
<sec:http pattern="/forgotPasswordPage" security="none" />
<sec:http pattern="/createAccountPage" security="none" />
<sec:http pattern="/createAccount" security="none" />
<sec:http authentication-manager-ref="authenticationManager">
<sec:intercept-url pattern="/secure/**" access="hasRole('ROLE_USER')" />
<sec:anonymous/>
<!-- sec:form-login/-->
<sec:csrf disabled="true"/>
<sec:form-login
login-page="/login/login.htm"
login-processing-url="/j_spring_security_check"
authentication-success-handler-ref="authenticationSuccessHandler"
authentication-failure-handler-ref="authenticationFailureHandler" />
<sec:remember-me
data-source-ref="dataSource"
user-service-ref="userDetailsService"/>
</sec:http>
<bean id="authenticationFailureHandler" class="com.ohadr.auth_flows.core.AuthenticationFailureHandler">
<constructor-arg value="/login/login.htm?login_error=1"/>
<property name="accountLockedUrl" value="/login/accountLocked.htm" />
</bean>
<!-- bean name="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/oauth/commence" />
<property name="useForward" value="false" />
</bean-->
<!-- bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.MediaTypeAwareAuthenticationEntryPoint">
<property name="realmName" value="butkec" />
</bean>
<bean id="oauthAccessDeniedHandler" class="org.springframework.security.oauth2.provider.error.MediaTypeAwareAccessDeniedHandler" /-->
<!-- for test purposes, work without JDBC
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider user-service-ref="userDetailsService"/>
</sec:authentication-manager>
<sec:user-service id="userDetailsService">
<sec:user name="admin" password="admin" authorities="ROLE_USER,ROLE_ADMIN" />
</sec:user-service>
-->
<!-- till here test -->
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider user-service-ref="userDetailsService" >
<sec:password-encoder hash="sha-256">
<sec:salt-source user-property="username"/>
</sec:password-encoder>
</sec:authentication-provider>
</sec:authentication-manager>
<!-- do not use Spring's; use mine, see below
bean id="userDetailsService"
class="org.springframework.security.provisioning.JdbcUserDetailsManager">
<property name="dataSource" ref="dataSource"/>
<property name="enableGroups" value="false"/>
<property name="rolePrefix" value="ROLE_"/>
</bean-->
<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<constructor-arg value="256"/>
</bean>
<!-- decide how you wanna work: in-mem repo, or jdbc impl: -->
<!-- bean class="com.ohadr.auth_flows.mocks.InMemoryAuthenticationAccountRepositoryImpl" /-->
<bean id="userDetailsService" class="com.ohadr.auth_flows.core.jdbc.JdbcAuthenticationAccountRepositoryImpl" />
<bean class="com.ohadr.auth_flows.core.jdbc.JdbcAuthenticationPolicyRepositoryImpl" />
<!-- data-source -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.jamonapi.proxy.JAMonDriver"/>
<property name="jdbcUrl"
value="jdbc:jamon:mysql://${com.ohadr.oauth2.db.host}:${com.ohadr.oauth2.db.port}/${com.ohadr.oauth2.db.schema}?jamonrealdriver=org.gjt.mm.mysql.Driver;useUnicode=true&characterEncoding=utf-8"/>
<property name="user" value="${com.ohadr.oauth2.db.username}"/>
<property name="password" value="${com.ohadr.oauth2.db.password}"/>
<property name="acquireIncrement" value="1"/>
<property name="idleConnectionTestPeriod" value="100"/>
<property name="maxPoolSize" value="10"/>
<property name="maxStatements" value="5"/>
<property name="minPoolSize" value="5"/>
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="port" value="587" />
<property name="username" value="${com.ohadr.auth-flows.mail.username}" />
<property name="password" value="${com.ohadr.auth-flows.mail.password}" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
</bean>
</beans>