Bonsoir,
je travaille sur un projet jee avec spring security ,mon problème c'est que je veux avoir des pages à accès direct sans authentification,(par exemple pour s'inscrire ) mais il m'oblige toujours de s'authentifier
voici mon fichier de configuration spring :
et web.xml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <!-- Déclaration du PropertyPlaceholderConfigurer --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/db.properties</value> </list> </property> </bean> <!-- Déclaration de la DATASOURCE --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${db.driver}" /> <property name="url" value="${db.url}" /> <property name="username" value="${db.username}" /> <property name="password" value="${db.password}" /> </bean> <!-- Stratégie de Sécurité : ressources et Remember me --> <security:http auto-config="true"> <!-- <security:intercept-url pattern="/inscriptionpro.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" /> --> <security:intercept-url pattern="/Messagerie.jsp" /> <security:intercept-url pattern="/inscriptionUti.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <security:intercept-url pattern="/login.jsp*" filters="none"/> <security:intercept-url pattern="/login-failure.jsp" filters="none"/> <security:intercept-url pattern="/logo*" filters="none"/> <security:intercept-url pattern="/objis.css" filters="none"/> <security:intercept-url pattern="/**" access="ROLE_PROFESSIONNEL,ROLE_CLIENT"/> <security:form-login login-page='/login.jsp' authentication-failure-url="/login-failure.jsp"/> <security:remember-me data-source-ref="dataSource"/> </security:http> <!-- Authentification via Database personalisée : Exemple avec table 'utilisateur' Attention à la colonne 'enabled' à ajouter --> <security:authentication-provider user-service-ref='myUserDetailsService' /> <bean id="myUserDetailsService" class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl"> <property name="dataSource" ref="dataSource"/> <property name="usersByUsernameQuery" value="SELECT login as username, password, enabled , nom, prenom FROM utilisateur WHERE login = ?"/> <property name="authoritiesByUsernameQuery" value="SELECT login as username, role FROM utilisateur WHERE login = ?"/> <!-- from role --> </bean> </beans>
s'il y a quelqu'un qui peut m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>demospringsecurity</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- - Filtre springSecurityFilterChain --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- - ContextLoaderListener : chargement fichiers de définition de beans --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <!-- - Fichiers XML de configuration, à charger par le ContextLoaderListener --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/objisapp-security.xml </param-value> </context-param> <!-- Servlet controleur de Struts --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Mapping des url avec la servlet --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- page d'accueil de l'application --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>![]()
Partager