Bonjour,
je suis débutant avec Spring security et jusque là tout va bien ça marche nikel.
Mon problème est le suivant je voudrais sécuriser mes méthodes dans mes servlets(j'utilise spring MVC) en fonction des accès utilisateurs, mais cela ne marche pas.
Par contre les dans les jsp avec <sec:authorize access="hasRole('ACCESS_SCAT_19')"> ça marche nikel mais comme la plupart de mes pages ont des traitements lourds, je trouve dommage de charger tous mes infos pour ensuite ne pas les "utiliser".
Voici ma config spring security :
Un extrait de mon controleur(ACCESS_SCAT_19 correspond au droit utilisateur permettant d'afficher la page) :
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 <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" 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-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <global-method-security pre-post-annotations="enabled"> </global-method-security> <http auto-config="true" use-expressions="true"> <!-- <intercept-url pattern="/secure/extreme/**" access="hasRole('ROLE_SUPERVISOR')"/> --> <intercept-url pattern="/secure/**" access="hasRole('ROLE_ADMIN')" /> <intercept-url pattern="/**" access="isAuthenticated()" /> <intercept-url pattern="/login.do" filters="none" /> <intercept-url pattern="/logout.do" filters="none" /> <intercept-url pattern="/about.do" filters="none" /> <intercept-url pattern="/timeout.do" filters="none" /> <intercept-url pattern="/chart/**" filters="none" /> <intercept-url pattern="/css/**" filters="none" /> <intercept-url pattern="/img/**" filters="none" /> <intercept-url pattern="/js/**" filters="none" /> <access-denied-handler error-page="/login.do?access_denied=true" /> <form-login login-page="/login.do" default-target-url="/index.do" always-use-default-target="true" authentication-failure-url="/login.do?login_error=true" /> <logout invalidate-session="true" logout-success-url="/login.do" /> <!-- Uncomment to enable X509 client authentication support <x509 /> --> <!-- Uncomment to limit the number of sessions a user can have --> <custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> <session-management session-authentication-strategy-ref="max" /> </http> <authentication-manager> <authentication-provider ref="authenticationDao" user-service-ref="authenticationDao" /> </authentication-manager> <beans:bean id="authenticationDao" class="server.DAO.hibernate.AuthentificationDaoImpl" /> <beans:bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> <beans:property name="sessionRegistry" ref="sessionRegistry" /> <beans:property name="expiredUrl" value="/login.do?session_expired=true" /> </beans:bean> <beans:bean id="max" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy"> <beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" /> <beans:property name="maximumSessions" value="2" /> </beans:bean> <beans:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" /> </beans:beans>
Voila en espérant que vous pourrez m'aider et merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 @RequestMapping(value = "/oraclehistorique.do", method = RequestMethod.GET) @PreAuthorize("hasRole('ACCESS_SCAT_19')") public ModelAndView oracleHistorique() { ModelAndView mvn = new ModelAndView("oraclehistorique"); return mvn; }
Cordialement,
Cleytus
Partager