a re introduction to spring security
play

A (re)introduction to Spring Security Agenda Before Spring - PDF document

A (re)introduction to Spring Security Agenda Before Spring Security: Acegi security Introducing Spring Security View layer security Whats coming in Spring Security 3 E-mail: craig@habuma.com Blog: http://www.springloaded.info


  1. A (re)introduction to Spring Security Agenda • Before Spring Security: Acegi security • Introducing Spring Security • View layer security • What’s coming in Spring Security 3 E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

  2. Before Spring Security There was... Acegi Security for Spring • Created by Ben Alex in 2003 • 1.0 released in March 2004 • Applies security rules using Servlet Filters and Spring AOP • Extremely powerful and flexible E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

  3. What Acegi Offered • Declarative Security • Keeps security details out of your code • Authentication and Authorization • Against virtually any user store • Support for anonymous sessions, concurrent sessions, remember-me, channel-enforcement, and much more • Spring-based, but can be used for non- Spring web frameworks E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma The Downside of Acegi “Every time you use Acegi...A fairy dies.” - Daniel Deiphouse http://netzooid.com/blog/2007/12/03/every-time-you- use-acegi/ E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

  4. Example Acegi Config <?xml version="1.0" encoding="UTF-8"?> </property> <beans xmlns="http://www.springframework.org/schema/beans" </bean> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <bean id="httpSessionIntegrationFilter" xsi:schemaLocation="http://www.springframework.org/schema/beans class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <property name="forceEagerSessionCreation" value="true" /> <bean id="filterChainProxy" </bean> class="org.acegisecurity.util.FilterChainProxy"> <bean id="filterSecurityInterceptor" <property name="filterInvocationDefinitionSource"> class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"> <value> <property name="authenticationManager" ref="authenticationManager" /> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON <property name="accessDecisionManager" ref="accessDecisionManager" /> PATTERN_TYPE_APACHE_ANT <property name="objectDefinitionSource"> /**=channelProcessingFilter,httpSessionIntegrationFilter, <value> logoutFilter,authenticationProcessingFilter,rememberMeProcessingFilter, CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON anonymousProcessingFilter,exceptionTranslationFilter,filterSecurityInterceptor PATTERN_TYPE_APACHE_ANT </value> /booger.htm=ROLE_BOOGER </property> </value> </bean> </property> <bean id="authenticationProcessingFilter" </bean> class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"> <bean id="anonymousProcessingFilter" <property name="authenticationManager" ref="authenticationManager"/> class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"> <property name="authenticationFailureUrl" value="/login.htm?login_error=1" /> <property name="key" value="foobar" /> <property name="defaultTargetUrl" value="/" /> <property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS" /> <property name="filterProcessesUrl" value="/j_acegi_security_check" /> </bean> <property name="rememberMeServices" ref="rememberMeServices" /> <bean id="anonymousAuthenticationProvider" </bean> class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"> <bean id="authenticationManager" <property name="key" value="foobar" /> class="org.acegisecurity.providers.ProviderManager"> </bean> <property name="providers"> � <bean id="rememberMeProcessingFilter" <list> � class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"> <ref bean="daoAuthenticationProvider" /> � <property name="rememberMeServices" ref="rememberMeServices" /> <ref bean="anonymousAuthenticationProvider" /> � <property name="authenticationManager" ref="authenticationManager" /> <ref bean="rememberMeAuthenticationProvider" /> � </bean> </list> � <bean id="rememberMeServices" </property> � class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"> </bean> � <property name="userDetailsService" ref="userDetailsService" /> <bean id="daoAuthenticationProvider" � <property name="key" value="roadRantz" /> class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"> � </bean> <property name="userDetailsService" � <bean id="rememberMeAuthenticationProvider" ref="userDetailsService" /> � class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"> </bean> � <property name="key" value="roadRantz" /> <bean id="userDetailsService" � </bean> class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"> <bean id="logoutFilter" <property name="dataSource" ref="dataSource" /> class="org.acegisecurity.ui.logout.LogoutFilter"> <property name="usersByUsernameQuery" <constructor-arg value="/home.htm" /> value="SELECT email as username, password, 'true' FROM Motorist WHERE email=?" /> <constructor-arg> <property name="authoritiesByUsernameQuery" <list> value="SELECT email as username, privilege FROM Motorist_Privileges mp, Motorist m WHERE <ref bean="rememberMeServices"/> mp.motorist_id = m.id AND m.email=?" /> <bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/> </bean> </list> <bean id="authenticationEntryPoint" </constructor-arg> class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"> </bean> <property name="loginFormUrl" value="/login.htm" /> <bean id="channelProcessingFilter" <property name="forceHttps" value="true" /> class="org.acegisecurity.securechannel.ChannelProcessingFilter"> </bean> <property name="channelDecisionManager" ref="channelDecisionManager" /> <bean id="accessDecisionManager" <property name="filterInvocationDefinitionSource"> class="org.acegisecurity.vote.UnanimousBased"> <value> <property name="allowIfAllAbstainDecisions" value="false" /> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON <property name="decisionVoters"> PATTERN_TYPE_APACHE_ANT <list> /login.htm=REQUIRES_SECURE_CHANNEL <bean class="org.acegisecurity.vote.RoleVoter" /> /j_acegi_security_check*=REQUIRES_SECURE_CHANNEL </list> /**=REQUIRES_INSECURE_CHANNEL </property> </value> </bean> </property> <bean id="exceptionTranslationFilter" </bean> class="org.acegisecurity.ui.ExceptionTranslationFilter"> </beans> <property name="authenticationEntryPoint" ref="authenticationEntryPoint" /> <property name="accessDeniedHandler"> <bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl"> <property name="errorPage" value="/error.htm" /> </bean> E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma What was in that XML? E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

  5. Introducing Spring Security Solution:Spring Security • All of the same goodness of Acegi • Plus some new stu � • Provides a new security namespace for Spring • Much less XML • Based on Spring, but can be used with non- Spring applications • Currently at version 2.0.5 • Version 3.0.0.RC1 is available E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

  6. From the home page “Spring Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring.” E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma What Spring Security Isn’t • Firewall or proxy server • OS-level security • JVM security • Identity management or single-sign-on • Protection against cross-site scripting E-mail: craig@habuma.com Blog: http://www.springloaded.info Source Code: svn://svn.geekisp.com/SiA svn://svn.geekisp.com/habuma

Recommend


More recommend