The ¡Anatomy ¡of ¡a ¡ ¡ Secure ¡Web ¡Applica6on ¡ ¡ Using ¡Java ¡ ¡ ¡ ¡ ¡ ¡
ApacheCon ¡NA ¡2015 ¡
¡
John ¡Field, ¡Pivotal ¡Services ¡@EMC ¡
Image: http://amhistory.si.edu/img/collections_xlarge/99-2741_428px.jpg
1
The Anatomy of a Secure Web Applica6on Using Java - - PowerPoint PPT Presentation
The Anatomy of a Secure Web Applica6on Using Java ApacheCon NA 2015 John Field, Pivotal Services @EMC 1 Image:
¡
Image: http://amhistory.si.edu/img/collections_xlarge/99-2741_428px.jpg
1
l John ¡Field ¡
l Security ¡Architect ¡at ¡ ¡
¡
¡
ApacheCon NA 2015 2
ApacheCon NA 2015
Picture of Oreo
3
ApacheCon NA 2015 4
ApacheCon NA 2015 5
l Deployment ¡of ¡an ¡Enterprise ¡Java ¡Web ¡Applica6on. ¡
l We ¡have ¡requirements ¡for: ¡ ¡
HTTPS
ApacheCon NA 2015 6
ApacheCon NA 2015 7
PAAS
Tomcat Server Java Web Application HTTPS LDAPS JDBC
X509 Certificate ApacheCon NA 2015 8
l Communications secured via SSL/TLS. l Users authenticate via enterprise LDAP. l Resource authorization via RBAC.
l Including Static and Dynamic Separation of Duties
l Audit logging for all application events
ApacheCon NA 2015 9
Tomcat Server Java Web Application HTTPS LDAPS JDBC
X509 Certificate ApacheCon NA 2015 10
PEP: AuthN & coarse- grained AuthZ PAP: Identities Policies PEP: Pages, controls, datum, AuthZ PEP: Audit Logging PEP: Confidentiality, Integrity PDP: PDP: Policy Decision
ApacheCon NA 2015 11
ApacheCon NA 2015 12
ApacheCon NA 2015 13
ApacheCon NA 2015 14
ApacheCon NA 2015 15
¡
Generate CA keys Generate self-signed CA certificate Generate server certificate signing request
ApacheCon NA 2015 16
¡
¡
¡
Remove passphrase from private key Sign server certificate request Generate a temporary PKCS12 keystore.
ApacheCon NA 2015 17
Use Java keytool to import PKCS12 into JKS key store for Web server
ApacheCon NA 2015 18
Use Java keytool to import CA cert into JKS truststore for client application
ApacheCon NA 2015 19
ApacheCon NA 2015 20
ApacheCon NA 2015 21
l Add the following to server.xml:
ApacheCon NA 2015 22
While you are at it, add the JEE Security Realm Provider Proxy jar. Put mykeystore in the indicated place
ApacheCon NA 2015 23
ApacheCon NA 2015 24
<security-constraint> <display-name>My Security Constraint</display-name> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> </web-resource-collection> <auth-constraint> </auth-constraint> </security-constraint> <login-config> <realm-name>MySecurityRealm</realm-name> <form-login-config> <form-error-page>/login/error.html</form-error-page> </form-login-config> </login-config> <url-pattern>/secured/*</url-pattern> <role-name>ROLE_DEMO_USER</role-name> <auth-method>FORM</auth-method> <form-login-page>/login/login.html</form-login-page>
ApacheCon NA 2015 25
Declarative coarse-grained authorization. Enforced high in the stack. HTML Form-based Authentication
ApacheCon NA 2015 26
ApacheCon NA 2015 27
Assume an LDAP server is already deployed. Focus on the PDP integration via Fortress Sentry
ApacheCon NA 2015 28
ApacheCon NA 2015 29
30 ApacheCon NA 2015
31
ApacheCon NA 2015
32 ApacheCon NA 2015
33 ApacheCon NA 2015
ApacheCon NA 2015 34
Focus on the PDP integration via Fortress Sentry
<Context reloadable="true"> < debug="0" resourceName="UserDatabase" defaultRoles="ROLE_DEMO2_SUPER_USER, DEMO2_ALL_PAGES, ROLE_PAGE1, ROLE_PAGE2, ROLE_PAGE3" containerType="TomcatContext" realmClasspath=”” /> </Context> ¡ Realm className= "org.openldap.sentry.tomcat.Tc7AccessMgrProxy"
ApacheCon NA 2015 35
36
ApacheCon NA 2015
37 ApacheCon NA 2015
38 ApacheCon NA 2015
39 ApacheCon NA 2015
40 ApacheCon NA 2015
41
<bean id="fsi" class= "org.springframework.security.web.access.intercept.FilterSecurityInterceptor"> <property name="authenticationManager" ref="authenticationManager"/> <property name="accessDecisionManager” ref="httpRequestAccessDecisionManager"/> <property name="securityMetadataSource"> <sec:filter-invocation-definition-source> </sec:filter-invocation-definition-source> </property> </bean>
<sec:intercept-url pattern="/com.mycompany.page1“ access=“ROLE_PAGE1“/>
ApacheCon NA 2015
42
<dependency> <groupId>org.springframework.security</groupId> <artifactId> </artifactId> <version>${spring.security.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId> </artifactId> <version>${spring.security.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId> </artifactId> <version>${spring.security.version}</version> </dependency> Spring-security-config
spring-security-web spring-security-core
ApacheCon NA 2015
43 ApacheCon NA 2015
44 ApacheCon NA 2015
add( { @Override protected void onSubmit( ... ) { { // do something here: } else { target.appendJavaScript( ";alert('Unauthorized');" ); } } }); new SecureIndicatingAjaxButton( "Page1", "Add" ) if( checkAccess( customerNumber )
As page is rendered, buttons are activated, per the user’s cached permissions. On submit, do programmatic authorization (instance-based) Page1.java, addButtons() private method
45 ApacheCon NA 2015
46
ApacheCon NA 2015
Just prior to database update, re-verify authorization for this instance. Page1DaoMgr.java, updatePage1() public method
47 ApacheCon NA 2015
48 ApacheCon NA 2015
49 ApacheCon NA 2015
ApacheCon NA 2015 50
ApacheCon NA 2015 51
ApacheCon NA 2015 52
ApacheCon NA 2015 53
PAAS
ApacheCon NA 2015 54
PAAS Java Servlet Container app.war LDAP RDMBS
ApacheCon NA 2015 55
VM Warden Container PAAS Java Servlet Container app.war VM Warden Container RDMBS
LDAP
ApacheCon NA 2015 56
VM Warden Container PAAS VM Warden Container RDMBS LDAPS:// JDBC:// Provided by PAAS HTTP:// HTTPS://
LDAP Java Servlet Container Existing Enterprise Service app.war Provided by PAAS
ApacheCon NA 2015 57
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 58
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 59
ApacheCon NA 2015 60
Browser CF Router HA Proxy DEA app.war
https://fortressdemo2.pcf.com/login.jsp
Client’s DNS resolves *.pcf.com to the CF entry point.
http://10.110.57.60:12345/login.jsp
CF Router maps app name “fortressdemo2” to IP and port. HA Proxy forwards request to the CF Router SSL Terminated Not visible
cloud
ApacheCon NA 2015 61
CF PAAS
HTTPS
ApacheCon NA 2015 62
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 63
ApacheCon NA 2015 64
ApacheCon NA 2015 65
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 66
shell> mvn clean package shell> cf push fortressdemo2 -p target/fortressdemo2.war –b https://github.com/johnpfield/java-buildpack.git
App to deploy Stack to use
ApacheCon NA 2015 67
ApacheCon NA 2015 68
RC39.jar
ApacheCon NA 2015 69
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 70
ApacheCon NA 2015 71
Hostname: vm-09bf580a-69a0-431c-9741-bb49c4f318b8 VNIC: eth0 Filesystem: /var/vcap/data/warden/depot/ IP: 10.110.57.60 Memory: 4Gb Warden Container “B”
Hostname: 17ruu5224qb VNIC: w-17ruu5224-qb-1 Filesystem: /home/vcap IP: 10.254.0.6 Memory: 1Gb
Warden Container “A”
Hostname: 17ruu5224qa VNIC: w-17ruu5224-qa-1 Filesystem: /home/vcap IP: 10.254.0.2 Memory: 1Gb VNIC: w-17ruu5224qa-0 IP: 10.254.0.1 Filesystem: ./w-17ruu5224qa/tmp/rootfs VNIC: w-17ruu5334qb-0 IP: 10.254.0.5 Filesystem: ./17wruu5224qb/tmp/rootfs
DEA VM PAAS (ESX Node)
ApacheCon NA 2015 72
CF Build packs CF service bindings Linux containers CF security perimeter, and request routing
What We Need to Understand:
ApacheCon NA 2015 73
ApacheCon NA 2015 74
ApacheCon NA 2015 75
ApacheCon NA 2015 76