Securing web applications using Java EE Dr Jim Briggs 1.

Slides:



Advertisements
Similar presentations
FI-WARE Testbed Access Control temporary solution.
Advertisements

Forms Authentication, Users, Roles, Membership Ventsislav Popov Crossroad Ltd.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
The Basic Authentication Scheme of HTTP. Access Restriction Sometimes, we want to restrict access to certain Web pages to certain users A user is identified.
Web Application Security SSE USTC Qing Ding. Agenda General security issues Web-tier security requirements and schemes HTTP basic authentication based.
Authentication Laurent Guérin / V 1.0 / 2008 – May ( for Telosys and + )
Http Web Authentication Web authentication is used to verify a users identity before allowing access to certain web pages On web browsers you get a login.
COMP 321 Week 12. Overview Web Application Security  Authentication  Authorization  Confidentiality Cross-Site Scripting Lab 12-1 Introduction.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
WEB2P security Java web application security Dr Jim Briggs.
Servlets and a little bit of Web Services Russell Beale.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
Stanford University EH&S A Service Oriented Architecture For Rich Internet Applications Sheldon M. Heitz.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Esri UC2013. Technical Workshop. Technical Workshop 2013 Esri International User Conference July 8–12, 2013 | San Diego, California Building Secure Applications.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
UNIT-V The MVC architecture and Struts Framework.
CSCI 6962: Server-side Design and Programming
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Session 11: Security with ASP.NET
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
3/26/2003Servlet Security 1 CSCI Research Topics in Computer Science --Web Security Instructor: Dr.Yang Students: Shiyou Li, Gang Zheng.
Remotely authenticating against the Service Framework.
Forms Authentication, Users, Roles, Membership Svetlin Nakov Telerik Corporation
Chapter 4: Core Web Technologies
Implementing ISA Server Publishing. Introduction What Are Web Publishing Rules? ISA Server uses Web publishing rules to make Web sites on protected networks.
Copyright 2000 eMation SECURITY - Controlling Data Access with
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Securing a Microsoft ASP.NET Web Application.
1 Web services and security ---discuss different ways to enforce security Presenter: Han, Xue.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
SSL, Single Sign On, and External Authentication Presented By Jeff Kelley April 12, 2005.
SE-2840 Dr. Mark L. Hornick1 Web Application Security.
Oracle Application Express Security. © 2009 Oracle Corporation Authentication Out-of-the-Box Pre-Configured Schemes LDAP Directory credentials Oracle.
Chapter 6: Authentications. Training Course, CS, NCTU 2 Overview  Getting Username and Password  Verifying Username and Password  Keeping The Verification.
SE-2840 Dr. Mark L. Hornick1 Web Application Security.
Dr. Mustafa Cem Kasapbaşı Security in ASP.NET. Determining Security Requirements Restricted File Types.
Chapter 6 Server-side Programming: Java Servlets
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Module 11: Securing a Microsoft ASP.NET Web Application.
Web Database Programming Week 7 Session Management & Authentication.
UMBC’s WebAuth Robert Banz – UMBC
Struts 2 introduction. Struts 2 framework Struts 2 A full-featured web application framework for the Java EE platform The Java Servlet API exposes the.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
PHP-based Authentication
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
PHP Secure Communications Web Technologies Computing Science Thompson Rivers University.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
Access control 2/18/2009. TOMCAT Security Model Declarative Security:  the expression of application security external to the application, and it allows.
©SoftMoore ConsultingSlide 1 Filters. Filters can be used in a web application to intercept, examine, and possibly transform requests or responses associated.
Security Issues With Web Based Systems. Security Issues Web Based Systems  Security can not be considered an add-on or afterthought  Security must be.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Slide 1 Web Application Security ©SoftMoore Consulting.
15 Copyright © 2004, Oracle. All rights reserved. Adding JAAS Security to the Client.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
COEN 350: Network Security E-Commerce Issues. Table of Content HTTP Authentication Cookies.
Securing Web Applications Lesson 4B / Slide 1 of 34 J2EE Web Components Pre-assessment Questions 1. Identify the correct return type returned by the doStartTag()
COOKIES AND SESSIONS.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
CS520 Web Programming Declarative Security (I) Chengyu Sun California State University, Los Angeles.
Daniel Doubrovkine (dblock[at]dblock[dot]org) Single Sign-On w/ Tomcat & WAFFLE 6/8/2010 Tomcat -> Waffle ->
Authentication & Authorisation Is the user allowed to access the site?
CS520 Web Programming Declarative Security (II)
IBM Certified WAS 8.5 Administrator
Web Systems Development (CSC-215)
CS5220 Advanced Topics in Web Programming Secure REST API
Information Retrieval and Web Design
Presentation transcript:

Securing web applications using Java EE Dr Jim Briggs 1

Introduction Security is a pervasive issue – All e-commerce systems require it Three aspects of security: – Confidentiality – Integrity – Availability To achieve these, we distinguish two functions: – authentication: how users prove who they say they are – authorisation: how access to specific resources is allowed or denied 2

Three areas to cover 1.HTTP and other authentication mechanisms 2.Application-managed security 3.Container-managed security 1.Declarative 2.Programmatic 3

AUTHENTICATION MECHANISMS 4

HTTP authentication 1 HTTP provides facilities for authentication – HTTP authentication operates on a challenge/response paradigm – If server receives a request for an access-protected object, and an acceptable Authorization header is not sent, the server responds with a "401 Unauthorized" status code. – The client must then resend the request with an Authorization header. Most browsers will prompt the user for a username and password. Most browsers cache this for the duration of the browser session; some will allow the user to save it between sessions. We leave it as an exercise for the reader as to whether storing a password on the client machine is secure or not! 5

HTTP authentication 2 Two mechanisms – Basic Authentication – passes usernames and passwords in clear text (actually in Base64 format, but this is easily translatable) – Digest Authentication – scrambles the password by sending a checksum (by default, MD5) of: the username the password a given nonce value (sent by the server with the 401 response) the HTTP method the requested URI Why are all of these necessary? HTTP authentication operates within a realm. A realm is essentially the store (e.g. file, database,...) against which user credentials are checked. 6

Transporting passwords Problem: Basic authentication sends passwords in clear Digest authentication better – only sends password digest Secure Sockets Layer (SSL) HTTPS – secure HTTP 7

Non-HTTP authentication Provide user with a login form (HTML) – Boxes for username and password – Typically provides link for forgotten password Username and password sent as normal form data Server-side processes it like any other form data 8

Identifying a logged-in user If using HTTP authentication, browser will resend credentials with all relevant requests – Server effectively rechecks each request If using application authentication, server will store user-id in session – Application needs to recheck every request 9

Java Authentication and Authorization Service (JAAS) Common to all Java platforms (apps, applets and servlets) Two basic concepts (interfaces): – Principal: represents an (authenticated) user – Role: group of principals who share common set of permissions 10

APPLICATION MANAGED SECURITY 11

Common features Mechanism to test authorisation – Code in every servlet Or every servlet extends one with the security in-built – Filter applied to all relevant servlets – Framework-specific mechanism (e.g. Interceptor in Struts2) – Java EE standard mechanism Mechanism to force authentication – Via HTTP – Via a form – Store result so that it can be reused 12

Java EE facilities request.getRemoteUser() request.getUserPrincipal() request.isUserInRole(role) Use session attributes to store the user's identity Use cookies to store username and password (can be persistent between browser sessions) 13

Checking login: business method public User login(String username, String password) throws Exception { Query q = em.createQuery("select p from Person p where p.username = :username and p.password = :password"); q.setParameter("username", username); q.setParameter("password", password); try { User u = (User) q.getSingleResult(); return u; } catch (NoResultException ex) { return null; } 14

Checking login: controller method user = userMgmt.login(username, password); if (user != null) { request.getSession().setAttribute("LoggedInUser", user); setMessage("Logged in as " + user.getUsername()); log.info(user.getUsername() + " logged in successfully"); return SUCCESS; } else { setMessage("Username and/or password not known"); this.addActionError("Username and/or password not known"); return Constants.LOGIN_FAILED; } 15

Authorisation: check access user = request.getSession().getAttribute("LoggedInUser"); if (user == null) { // not logged in! //redirect to a login page if (user.inRole("admin") { if (securityManager.isUserinRole(user, "admin")) { if (securityManager.isAdmin(user)) { 16

Pros and cons of application-managed security Pro: complete control Pro: can fine-tune for performance Con: you might forget to put it in a method Con: managing site-wide may be a problem 17

CONTAINER MANAGED SECURITY 18

Container managed security Standard set of functionality Security can span a set of separate web applications (single sign-on) 19

Java EE @RunAs 20

Java EE Configuration Container (e.g. Glassfish) – Configure: realm (and implementation) for container to use security role mappings (via glassfish-web.xml) – assign principals and/or groups to roles Application – web.xml login configuration – basic/digest/form/certificate security roles security constraints – URL constraints – authentication constraints – data (transport) constraint 21

Accessing a Java EE application 22

Accessing a Java EE application 23

Accessing a Java EE application 24

Accessing a Java EE application 25

Accessing a Java EE application 26