A (re)introduction to Spring Security



Similar documents
Spring Security 3.

Acegi Security. What is Acegi Security Key features Conclusion Examples in reality References. Aureliusz Rempala Emily Brand Fan Wang

Spring Security. Reference Documentation. 2.0.x. Copyright

Spring Security 3. rpafktl Pen source. intruders with this easy to follow practical guide. Secure your web applications against malicious

Pierce County IT Department GIS Division Xuejin Ruan Dan King

Advanced OpenEdge REST/Mobile Security

Application Security. Petr Křemen.

<Insert Picture Here> Hudson Security Architecture. Winston Prakash. Click to edit Master subtitle style

Reference Documentation

entries_inheriting, 208

ADMINISTERING ADOBE LIVECYCLE MOSAIC 9.5

Java Enterprise Security. Stijn Van den Enden

Apache Roller, Acegi Security and Single Sign-on

SSO Plugin. Authentication service for HP, Kinetic, Jasper, SAP and CA products. J System Solutions. JSS SSO Plugin Authentication service

SSO Plugin. Authentication service for HP, Kinetic, Jasper, SAP and CA products. J System Solutions. Page 1 of 23.

Define BA Server Advanced Security

Integrating IBM Cognos 8 BI with 3rd Party Auhtentication Proxies

Apache Ki (formerly JSecurity) DevNexus

Space Details. Available Pages. BI Server Documentation - Latest. Description:

NETASQ ACTIVE DIRECTORY INTEGRATION

Master s Thesis EEG/ERP Portal Security in New Technologies

Securing JAX-RS RESTful services. Miroslav Fuksa (software developer) Michal Gajdoš (software developer)

enterprise^ IBM WebSphere Application Server v7.0 Security "publishing Secure your WebSphere applications with Java EE and JAAS security standards

Securing a Web Service

Identity Management in Liferay Overview and Best Practices. Liferay Portal 6.0 EE

Crawl Proxy Installation and Configuration Guide

Contents. Pentaho Corporation. Version 5.1. Copyright Page. Introduction. Implement Advanced Security. Switch to MS Active Directory.

Implementing CAS. Adam Rybicki Jasig Conference, San Diego, CA March 7, 2010

Web Application Access Control with Java SE Security

Q&A Session for Understanding Atrium SSO Date: Thursday, February 14, 2013, 8:00am Pacific

Eylean server deployment guide

Authentication Methods

Securing RESTful Web Services Using Spring and OAuth 2.0

Integration of Shibboleth and (Web) Applications

Configuring BEA WebLogic Server for Web Authentication with SAS 9.2 Web Applications

Single Sign-On Research and Expansion Based On CAS

Table of contents. Jasig CAS support for the Spring Security plugin.

How To Configure The Jasig Casa Single Sign On On A Workstation On Ahtml.Org On A Server On A Microsoft Server On An Ubuntu (Windows) On A Linux Computer On A Raspberry V

Web Services Security: OpenSSO and Access Management for SOA. Sang Shin Java Technology Evangelist Sun Microsystems, Inc. javapassion.

Active Directory Integration

From the Intranet to Mobile. By Divya Mehra and Stian Thorgersen

ClearPass A CAS Extension Enabling Credential Replay

Enabling single sign-on for Cognos 8/10 with Active Directory

Unlocking the Secrets of Alfresco Authentication. Mehdi BELMEKKI,! Consultancy Team! Alfresco!

JASPERREPORTS SERVER ADMINISTRATOR GUIDE

Apache Sling A REST-based Web Application Framework Carsten Ziegeler cziegeler@apache.org ApacheCon NA 2014

Kerberos and Windows SSO Guide Jahia EE v6.1

Setting Up CAS with Ofbiz 5

PRiSM Security. Configuration and considerations

Please return this document to when complete.

ipad or iphone with Junos Pulse and Juniper SSL VPN appliance Authenticating Users Using SecurAccess Server by SecurEnvoy

Single Sign-On Implementation Guide

Spring Security SAML module

Identity Management with Spring Security. Dave Syer, VMware, SpringOne 2011

XAP 10 Global HTTP Session Sharing

About Me. Software Architect with ShapeBlue Specialise in. 3 rd party integrations and features in CloudStack

External Authentication with Juniper SSL VPN appliance Authenticating Users Using SecurAccess Server by SecurEnvoy

Integrating Webalo with LDAP or Active Directory

esoc SSA DC-I Part 1 - Single Sign-On and Access Management ICD

Tutorial for Spring DAO with JDBC

UPGRADING TO XI 3.1 SP6 AND SINGLE SIGN ON. Chad Watson Sr. Business Intelligence Developer

Collax Web Security. Howto. This howto describes the setup of a Web proxy server as Web content filter.

Integrating a Hitachi IP5000 Wireless IP Phone

Spring 3.1 to 3.2 in a Nutshell. Sam Brannen Senior Software Consultant

ASAV Configuration Advanced Spam Filtering

USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

External Authentication with Citrix Secure Gateway - Presentation server Authenticating Users Using SecurAccess Server by SecurEnvoy

FileCloud Security FAQ

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports Server 6i

JBoss Portlet Container. User Guide. Release 2.0

Xerox DocuShare Security Features. Security White Paper

Spring Security CAS Plugin - Reference Documentation. Burt Beckwith. Version M1

VIDEO intypedia007en LESSON 7: WEB APPLICATION SECURITY - INTRODUCTION TO SQL INJECTION TECHNIQUES. AUTHOR: Chema Alonso

BlueZone Integration Server

Web Applications and Struts 2

OBIEE 11g Security it s as easy as 1-2-3!

Fairsail. Implementer. Fairsail to Active Directory Synchronization. Version 1.0 FS-PS-FSAD-IG R001.00

The end. Carl Nettelblad

Access Management Analysis of some available solutions

Securing access to Citrix applications using Citrix Secure Gateway and SafeWord. PremierAccess. App Note. December 2001

What s new in Spring 3.1?

Web Application Report

Elluminate Live! Access Guide. Page 1 of 7

Microsoft Outlook Web Access 2013 Authenticating Users Using SecurAccess Server by SecurEnvoy

Supporting Multi-tenancy Applications with Java EE

Agenda. How to configure

Alert Notification of Critical Results (ANCR) Public Domain Deployment Instructions

AVG Business Secure Sign On Active Directory Quick Start Guide

How To Secure Your Data Center From Hackers

Security IIS Service Lesson 6

JVA-122. Secure Java Web Development

Web Application Architecture (based J2EE 1.4 Tutorial)

Configuring EPM System for SAML2-based Federation Services SSO

Authentication and Single Sign On

Transcription:

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

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

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 The Downside of Acegi Every time you use Acegi...A fairy dies. - Daniel Deiphouse http://netzooid.com/blog/2007/12/03/every-time-youuse-acegi/

Example Acegi Config <?xml version="1.0" encoding="utf-8"?> <beans xmlns="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-2.0.xsd"> <bean id="filterchainproxy" class="org.acegisecurity.util.filterchainproxy"> <property name="filterinvocationdefinitionsource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /**=channelprocessingfilter,httpsessionintegrationfilter, logoutfilter,authenticationprocessingfilter,remembermeprocessingfilter, anonymousprocessingfilter,exceptiontranslationfilter,filtersecurityinterceptor </value> </property> <bean id="authenticationprocessingfilter" class="org.acegisecurity.ui.webapp.authenticationprocessingfilter"> <property name="authenticationmanager" ref="authenticationmanager"/> <property name="authenticationfailureurl" value="/login.htm?login_error=1" /> <property name="defaulttargeturl" value="/" /> <property name="filterprocessesurl" value="/j_acegi_security_check" /> <property name="remembermeservices" ref="remembermeservices" /> <bean id="authenticationmanager" class="org.acegisecurity.providers.providermanager"> <property name="providers"> <list> <ref bean="daoauthenticationprovider" /> <ref bean="anonymousauthenticationprovider" /> <ref bean="remembermeauthenticationprovider" /> </list> </property> <bean id="daoauthenticationprovider" class="org.acegisecurity.providers.dao.daoauthenticationprovider"> <property name="userdetailsservice" ref="userdetailsservice" /> <bean id="userdetailsservice" class="org.acegisecurity.userdetails.jdbc.jdbcdaoimpl"> <property name="datasource" ref="datasource" /> <property name="usersbyusernamequery" value="select email as username, password, 'true' FROM Motorist WHERE email=?" /> <property name="authoritiesbyusernamequery" value="select email as username, privilege FROM Motorist_Privileges mp, Motorist m WHERE mp.motorist_id = m.id AND m.email=?" /> <bean id="authenticationentrypoint" class="org.acegisecurity.ui.webapp.authenticationprocessingfilterentrypoint"> <property name="loginformurl" value="/login.htm" /> <property name="forcehttps" value="true" /> <bean id="accessdecisionmanager" class="org.acegisecurity.vote.unanimousbased"> <property name="allowifallabstaindecisions" value="false" /> <property name="decisionvoters"> <list> <bean class="org.acegisecurity.vote.rolevoter" /> </list> </property> <bean id="exceptiontranslationfilter" class="org.acegisecurity.ui.exceptiontranslationfilter"> <property name="authenticationentrypoint" ref="authenticationentrypoint" /> <property name="accessdeniedhandler"> <bean class="org.acegisecurity.ui.accessdeniedhandlerimpl"> <property name="errorpage" value="/error.htm" /> </property> <bean id="httpsessionintegrationfilter" class="org.acegisecurity.context.httpsessioncontextintegrationfilter"> <property name="forceeagersessioncreation" value="true" /> <bean id="filtersecurityinterceptor" class="org.acegisecurity.intercept.web.filtersecurityinterceptor"> <property name="authenticationmanager" ref="authenticationmanager" /> <property name="accessdecisionmanager" ref="accessdecisionmanager" /> <property name="objectdefinitionsource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /booger.htm=role_booger </value> </property> <bean id="anonymousprocessingfilter" class="org.acegisecurity.providers.anonymous.anonymousprocessingfilter"> <property name="key" value="foobar" /> <property name="userattribute" value="anonymoususer,role_anonymous" /> <bean id="anonymousauthenticationprovider" class="org.acegisecurity.providers.anonymous.anonymousauthenticationprovider"> <property name="key" value="foobar" />! <bean id="remembermeprocessingfilter"! class="org.acegisecurity.ui.rememberme.remembermeprocessingfilter">! <property name="remembermeservices" ref="remembermeservices" />! <property name="authenticationmanager" ref="authenticationmanager" />!! <bean id="remembermeservices"! class="org.acegisecurity.ui.rememberme.tokenbasedremembermeservices">! <property name="userdetailsservice" ref="userdetailsservice" />! <property name="key" value="roadrantz" />!! <bean id="remembermeauthenticationprovider"! class="org.acegisecurity.providers.rememberme.remembermeauthenticationprovider">! <property name="key" value="roadrantz" />! <bean id="logoutfilter" class="org.acegisecurity.ui.logout.logoutfilter"> <constructor-arg value="/home.htm" /> <constructor-arg> <list> <ref bean="remembermeservices"/> <bean class="org.acegisecurity.ui.logout.securitycontextlogouthandler"/> </list> </constructor-arg> <bean id="channelprocessingfilter" class="org.acegisecurity.securechannel.channelprocessingfilter"> <property name="channeldecisionmanager" ref="channeldecisionmanager" /> <property name="filterinvocationdefinitionsource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /login.htm=requires_secure_channel /j_acegi_security_check*=requires_secure_channel /**=REQUIRES_INSECURE_CHANNEL </value> </property> </beans> What was in that XML?

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

From the home page Spring Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. 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

Features Authentication Web URL and method authorization Channel (HTTP/HTTPS) security Domain based security (ACLs) Also plays well with other Spring components WSS/WS-Security with Spring-WS Flow authorization with Spring WebFlow Uses Spring 3 s SpEL Key concepts Filters Authentication Repositories Web authorization Method authorization

DelegatingFilterProxy In WEB-INF/web.xml: <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> Proxies requests to a bean with ID springsecurityfilterchain Authentication Several choices Form Basic LDAP Kerberos Container (eg. Tomcat) JAAS JA-SIG CAS OpenID SiteMinder Atlassian Crowd OpenID X.509 Digest

Simpler Configuration <?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-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd"> <http auto-config="true"> <intercept-url pattern="/addrant.htm" access="role_motorist" /> <intercept-url pattern="/home.htm" requires-channel="http" /> <intercept-url pattern="/login.htm" requires-channel="https" /> <form-login login-page="/login.htm" /> </http> <authentication-provider user-service-ref="userservice" /> <jdbc-user-service id="userservice" data-source-ref="datasource" /> </beans:beans> <http>: The magic element The central configuration element for web security <intercept-url> declares a page to be secured (and how it should be secured) <form-login> refers to a login page The auto-config attribute automatically configures support HTTP Basic authentication, Logout, Remember-Me, and Anonymous sessions In fact, it also automatically creates a login page for you

More on <http> May also contain... <access-denied-handler> <anonymous> <concurrency-control> <form-login> <http-basic> <intercept-url> <logout> <openid-login> <port-mappings> <remember-me> <session-management> <x509> Even more on <http> Has these attributes servlet-api-provision path-type lowercase-comparisons realm entry-point-ref access-decision-manager-ref access-denied-page once-per-request create-session

<authentication-provider> Declares an authentication provider Refers to a user details service Optionally may contain a user details service: <authentication-provider> <jdbc-user-service data-source-ref="datasource" /> </authentication-provider> Declare as many providers as you need About <jdbc-user-service> Defaults to specific SQL User details: User privileges: Can be overridden... SELECT username,password,enabled FROM users WHERE username=? SELECT username,authority FROM authorities WHERE username=? <authentication-provider> <jdbc-user-service data-source-ref="datasource" users-by-username-query= "select username, password, true FROM spitter WHERE username=?" authorities-by-username-query= "select username,authority FROM spitter_privileges WHERE username=?" /> </authentication-provider>

Securing methods Two ways... Intercept methods <beans:bean id="userservice" class="com.habuma.user.useradminserviceimpl"/> <intercept-methods access-decision-manager-ref="accessdecisionmanager"> <protect method="adduser" access="role_admin"/> </intercept-methods> </beans:bean> Annotation-driven Using @Secured <global-method-security secured-annotations="enabled" /> Using JSR-250 annotations (e.g., @RolesAllowed) <global-method-security jsr250-annotations="enabled" /> JSR-250 @DenyAll public class Bank { @RolesAllowed("ROLE_TELLER") void deposit(account account, float amount) { //... } }

@Secured public class Bank { @Secured("ROLE_TELLER") void deposit(account account, float amount) { //... } } View layer security

Spring Security JSP tags Controls what gets rendered Includes... <security:authorize> <security:authentication> <security:accesscontrollist> For you Velocity fans... $authz JSP tag example <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>... <security:authorize ifanygranted="role_anonymous"> <p>please login:</p>... </security:authorize> <security:authorize ifnonegranted="role_anonymous"> <p>welcome, <security:authentication property="principal.username"/>!</p> </security:authorize>

What s new in Spring Security 3 Expression-based security Uses Spring Expression Language SpEL Flexible security rules Can be used to define authorization rules for web requests and methods

Expression elements hasrole(string) hasanyrole(string) hasipaddress( 192.168.1.2/24 ) haspermission(string) isanonymous isrememberme isfullyauthenticated authentication permitall, denyall access to method args and return objects Expressions & web security <http use-expressions="true"> <intercept-url pattern="/secure/**" access="hasrole('role_supervisor') and hasipaddress('192.168.1.2')" />... </http>

Pre- and Post- annotations Four new annotations... @PreAuthorize - Permits access if expression evaluates to true @PostFilter - Filters a collection return value according to expression evaluation @PreFilter - Filters collection method arguments according to expression evaluation @PostAuthorize - Restricts access to a method s return value @PreAuthorize Allow method access if user has ROLE_USER role @PreAuthorize("hasRole('ROLE_USER')") public void create(contact contact); Allow method access if user has admin permission on the contact object @PreAuthorize("hasPermission(#contact, 'admin')") public void deletepermission(contact contact, Sid recipient, Permission permission); Allow method access if the user has ROLE_TELLER role and if the deposit will reconcile overdraft @PreAuthorize("hasRole('ROLE_TELLER') and (#account.balance + #amount >= -#account.overdraft)") void deposit(account account, double amount) {...}

@PostFilter Allow access if the user has ROLE_USER role. Filter the list to include only those objects for which user has read or admin permission. @PreAuthorize("hasRole('ROLE_USER')") @PostFilter("hasPermission(filterObject, 'read') or haspermission(filterobject, 'admin')") public List getall(); Restructuring Historically, most of Spring Security contained in a single JAR Some split packages...not OSGi-friendly Spring Security 3, split across ~7 JAR files More modular...and OSGi-friendly

Summary Final thoughts Spring Security picks up where Acegi left o! Extremely powerful and flexible security framework Spring-based, but can be used to secure non-spring apps