Apache Ki (formerly JSecurity) DevNexus - 2009



Similar documents
Apache Shiro - Executive Summary

Spring Security 3.

Security for Java Web Applications Using Apache Shiro

CS506 Web Design and Development Solved Online Quiz No. 01

Reference Documentation

JVA-122. Secure Java Web Development

Java EE 6 New features in practice Part 3

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

Qualtrics Single Sign-On Specification

TIBCO Spotfire Platform IT Brief

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

The HTTP Plug-in. Table of contents

Web Security (SSL) Tecniche di Sicurezza dei Sistemi 1

Use Enterprise SSO as the Credential Server for Protected Sites

Lecture 9: Application of Cryptography

Multi Factor Authentication API

Complete Java Web Development

IBM WebSphere Server Administration

Course Name: Course in JSP Course Code: P5

Spring Security SAML module

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

Using jlock s Java Authentication and Authorization Service (JAAS) for Application-Level Security

Balamaruthu Mani. Supervisor: Professor Barak A. Pearlmutter

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Introduction...3 Terms in this Document...3 Conditions for Secure Operation...3 Requirements...3 Key Generation Requirements...

Transport Layer Security Protocols

Java Application Developer Certificate Program Competencies

ClearPass A CAS Extension Enabling Credential Replay

Liferay Enterprise ecommerce. Adding ecommerce functionality to Liferay Reading Time: 10 minutes

WebSphere Server Administration Course

Apache Derby Security. Jean T. Anderson

Xerox DocuShare Security Features. Security White Paper

MOTOROLA MESSAGING SERVER SERVER AND MOTOROLA MYMAIL DESKTOP PLUS MODULE OVERVIEW. Security Policy REV 1.3, 10/2002

Copyright 2014 Jaspersoft Corporation. All rights reserved. Printed in the U.S.A. Jaspersoft, the Jaspersoft

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

Intellicus Single Sign-on

Webmail Using the Hush Encryption Engine

WebSphere Training Outline

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

How encryption works to provide confidentiality. How hashing works to provide integrity. How digital signatures work to provide authenticity and

SecureDoc Disk Encryption Cryptographic Engine

Oracle WebLogic Server 11g Administration

How To Login To The Mft Internet Server (Mft) On A Pc Or Macbook Or Macintosh (Macintosh) With A Password Protected (Macbook) Or Ipad (Macro) (For Macintosh) (Macros

Apache Roller, Acegi Security and Single Sign-on

Design Notes for an Efficient Password-Authenticated Key Exchange Implementation Using Human-Memorable Passwords

Criteria for web application security check. Version

SkyRecon Cryptographic Module (SCM)

Converting Java EE Applications into OSGi Applications

Sophos Mobile Control Technical guide

Chapter 17. Transport-Level Security

JAAS Java Authentication and Authorization Services

Final Year Project Interim Report

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

Configuring Nex-Gen Web Load Balancer

Crawl Proxy Installation and Configuration Guide

Apache Jakarta Tomcat

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

Advanced OpenEdge REST/Mobile Security

Computer System Management: Hosting Servers, Miscellaneous

Using weblock s Servlet Filters for Application-Level Security

Top Ten Web Application Vulnerabilities in J2EE. Vincent Partington and Eelco Klaver Xebia

MIGRATING DESKTOP AND ROAMING ACCESS. Migrating Desktop and Roaming Access Whitepaper

Single Sign-on (SSO) technologies for the Domino Web Server

CRYPTOGRAPHY AS A SERVICE

Oracle WebLogic Server

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

2012 LABVANTAGE Solutions, Inc. All Rights Reserved.

Securing Data on Microsoft SQL Server 2012

Security Technical. Overview. BlackBerry Enterprise Service 10. BlackBerry Device Service Solution Version: 10.2

The end. Carl Nettelblad

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Securing RESTful Web Services Using Spring and OAuth 2.0

GlassFish Security. open source community experience distilled. security measures. Secure your GlassFish installation, Web applications,

Oracle Database Security and Audit

3 Techniques for Database Scalability with Hibernate. Geert Bevin - SpringOne 2009

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

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

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

Safewhere*Identify 3.4. Release Notes

Using Foundstone CookieDigger to Analyze Web Session Management

Authenticate and authorize API with Apigility. by Enrico Zimuel Software Engineer Apigility and ZF2 Team

SBClient SSL. Ehab AbuShmais

GravityLab Multimedia Inc. Windows Media Authentication Administration Guide

Web Services for Management Perl Library VMware ESX Server 3.5, VMware ESX Server 3i version 3.5, and VMware VirtualCenter 2.5

TROUBLESHOOTING RSA ACCESS MANAGER SINGLE SIGN-ON FOR WEB-BASED APPLICATIONS

Redpaper Axel Buecker Kenny Chow Jenny Wong

New Features... 1 Installation... 3 Upgrade Changes... 3 Fixed Limitations... 4 Known Limitations... 5 Informatica Global Customer Support...

Kentico CMS security facts

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Configuring Security Features of Session Recording

Introduction to Apache Roller. Matt Raible Apache Roller Committer June 2007

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

Glassfish, JAVA EE, Servlets, JSP, EJB

PHP Integration Kit. Version User Guide

Enabling SSL and Client Certificates on the SAP J2EE Engine

Shibboleth Identity Provider (IdP) Sebastian Rieger

A (re)introduction to Spring Security

Transcription:

Apache Ki (formerly JSecurity) DevNexus - 2009

Introduction Jeremy Haile Project Co-Founder VP Product Development, WeTheCitizens

Agenda What is Apache Ki? Terminology Authentication, Authorization, Session Management, Cryptography Modules/Support Getting Started/Demo Questions

What is Ki? Simple, security API for Java Apache Incubator project Not tied to any framework or container - can run standalone Authentication, authorization, session management, cryptography

Why the new name? Trademark concerns over JSecurity Ki = Fortress (surrounded by moat) in Japanese Ki (pronounced key) works well with lock/ key allusions Doesn t tie us to Java in the future Super short package names and jar files!

Why another security framework? JAAS - confusing APIs, over-limiting, not good for application-level security Spring Security - tied to Spring Framework, uses unusual terminology None of the libraries support dynamic, runtime security changes out-of-the-box No libraries supported cross-domain sessions

Project Goals Simple to configure, yet powerful Easy to plugin custom authentication/ authorization Clean object model making use of Java 5+ features (annotations, generics) Support dynamic, instance-level security out of the box Sessions not tied to web or EJBs

Terminology Realm - data access object for an application s security components (users, roles, permissions) Subject - representation of an application user Principals - a subject s identifying attributes (e.g. username, user ID, social security #)

Terminology (cont.) Credentials - secret information known only to a user used to verify identity Permission - atomic representation of ability to perform an action Role - a named collection of permissions

Ki Architecture Subject JSecurityManager Authentication Authorization Session Management Cryptography API Pluggable Realms (one or more) Session DAO JDBC Realm LDAP Realm Custom Realm Session Cache

Authentication The process of verifying someone is who they claim to be Most commonly involves a username and password

Authentication in Ki Most access to Ki is via Subject interface Web environments get by calling SecurityUtils.getSubject() Authenticate by calling Subject.login(...) Throws exception if authentication fails

Authentication Example UsernamePasswordToken token = new UsernamePasswordToken(username, password); // Remember me is built in - just set to true: token.setrememberme( true ); try { Subject subject = SecurityUtils.getSubject(); subject.login(token); // Variety of AuthenticationException subclasses can be caught } catch (UnknownAccountException uae) { // User account not found } catch (IncorrectCredentialsException ice) { // Password wrong } catch (AuthenticationException e) { // Other auth error }

Authorization The process of determining if someone can perform a specific action Ki supports using roles and/or permissions for authorization Ki doesn t limit your data model Object or string based permissions Supports instance-level permissions

Permissions Most atomic element of authorization Not related to a user Ki supports two forms: Object-based - extend Ki s Permission interface String-based - converted to object by PermissionResolver (default creates WildcardPermissions)

WildcardPermission Powerful string representation of permissions Simple - clearcache generatereports Multi-level - users:edit users:delete Instance level - newsletter:send:13

WildcardPermission (cont.) Wildcards newsletter:*:13 (e.g. user allowed to perform any action for ID 13) Comma-lists newsletter:send:13,14,15 (e.g. user allowed to send for ID13, 14, and 15) Can grant wildcards, but always check specific instance newsletter:delete:13

Roles Named collection of permissions Users associated with a role typically inherit the permissions associated with it Allows granting sets of permissions to users Ki doesn t have a Role class - up to the Realm

Authorization in Ki Authorization mechanisms: Programmatic (via Subject interface) Declarative URL security (web.xml or jsecurity.ini) Annotation-based method security JSP tag-based

Programmatic Authorization // Most common usage - obtain Subject from Thread Local Subject subject = SecurityUtils.getSubject(); // Can programmatically check role if( subject.hasrole( "manager" ) ) { // Logic for managers } // Or programmatically check permissions if( subject.ispermitted( "message:delete" ) ) { // Allow user to delete a message } // Many other authorization methods on Subject subject.checkpermission(...); subject.hasallroles(...); etc.

Object and String Permissions // Permissions can be checked using object-based permissions PrinterPermission perm = new PrinterPermission( hplaserjet ); if( subject.ispermitted( perm ) {... } // or string-based permissions if( subject.ispermitted( printer:hplaserjet ) {... }

URL Authorization INI web configuration (more on this later) [urls] # Allow anonymous access /s/signup=anon # Require roles for access /s/manageusers=roles[admin] # Require permissions for access /s/manageusers=perms[user:manage] # Require user to be authenticated /s/**=authc

Annotation Authorization // Will automatically throw an AuthorizationException if caller // doesn t have required role @RequiresRoles( manager ) public String edituser(...) { } // Will automatically throw an AuthorizationException if caller // doesn t have required permission @RequiresPermissions( user:edit ) public String edituser(...) { }

JSP Tag Authorization <%-- Import JSecurity permissions --%> <%@ taglib prefix="jsec" uri="http://www.jsecurity.org/tags" %> <%-- Check permissions --%> <jsec:haspermission name="user:manage">...</jsec:haspermission> <jsec:lackspermission name="user:manage">...</jsec:lackspermission> <%-- Check roles --%> <jsec:hasrole name="admin">...</jsec:hasrole> <jsec:lacksrole name="admin">...</jsec:lacksrole> <%-- Some other tags... --%> <jsec:authenticated>...</jsec:authenticated> <jsec:user>...</jsec:user> <jsec:guest>...</jsec:guest>

Realms Encapsulates both authentication and authorization Built in realms for JDBC, LDAP, property files, etc. Or create custom Realm for your data model Usually custom Realms will extend AuthorizingRealm

Custom Realm Example (authentication) // From Spring-Hibernate sample app public class SampleRealm extends AuthorizingRealm { public SampleRealm() { setcredentialsmatcher(new Sha256CredentialsMatcher()); } // Superclass will compare credentials using an Sha256 hash as specified above protected AuthenticationInfo dogetauthenticationinfo(authenticationtoken authctoken)... { UsernamePasswordToken token = (UsernamePasswordToken) authctoken; } User user = userdao.finduser(token.getusername()); if( user!= null ) { return new SimpleAuthenticationInfo(user.getId(), user.getpassword(), getname()); } else { return null; }

Custom Realm Example (authorization) // From Spring-Hibernate sample app // Retrieve user info from DAO and return AuthorizationInfo protected AuthorizationInfo dogetauthorizationinfo(principalcollection principals) { Long userid = (Long) principals.fromrealm(getname()).iterator().next(); User user = userdao.getuser(userid); if( user!= null ) { SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); for( Role role : user.getroles() ) { info.addrole(role.getname()); info.addstringpermissions( role.getpermissions() ); } return info; } else { return null; } }

Session Management Supports heterogeneous clients Does not require HTTP environment (works with server-side service, Swing client, applets, etc.) POJO-based (IoC friendly) Can be used for Single-Sign On

Session Management (cont.) Temporal-based record (start, stop, last access) Can transparently be used to back HttpSession Session event listener support Supports inactivity/expiration Allows setting attributes (similar to HttpSession)

Ki Sessions // Access sessions via the subject - session created automatically Session session = subject.getsession(); // Session only returned if it already exists Session session = subject.getsession(false); // Can perform a variety of session operations session.setattribute( "userid", user.getid() ); session.getattribute( userid ); session.getlastaccesstime();

Session Data Can configure to use any storage mechanism (file system, memory, distributed cache, JDBC) Allows easy ability to cluster (Terracotta, GigaSpaces, etc.)

Cryptography Interface driven, POJO-based Simplified wrapper of complicated JCE infrastructure Easy to understand API (ciphers, hashes, etc.)

Ciphers A cipher is a cryptographic algorithm that encrypts and decrypts data using public and/or private keys Symmetric cipher - uses the same key to encrypt and decrypt Asymmetric cipher - uses one key to encrypt and another to decrypt

Ki Ciphers public interface Cipher { byte[] encrypt(byte[] raw, byte[] encryptionkey); byte[] decrypt(byte[] encrypted, byte[] decryptionkey); } Default implementations exist (BlowfishCipher, etc.) Encrypt user identities, such as remember me, cookies, etc.

Hashes A cryptographic hash is a one-way, irreversible conversion of an input source Commonly used for passwords Can be used on anything (files, streams, etc.)

//some examples: new Md5Hash( blah ).tohex(); Ki Hashes //File MD5 Hash value for checksum: new MD5Hash( afile ).tohex(); //store a password, but not in raw form: new Sha256(aPassword).toBase64(); Cleaner OO-API compared to JDK MessageDigest and Commons Digest Built-in hex/base64 conversion Built-in support for salts/repeated hashing

Modules/Support Packaged as modules (jsecurity-core, jsecurity-spring, jsecurity-ehcache,...) Web module for integration with web applications Spring Framework integration Grails plugin Guice, JBoss support on the way (usable now, but not officially supported)

<filter-mapping> <filter-name>jsecurityfilter</filter-name> <url-pattern>/s/*</url-pattern> </filter-mapping> Web Integration <!-- Excerpt from the Spring-Hibernate sample app --!> <filter> <filter-name>jsecurityfilter</filter-name> <!-- The below class is for Spring/web - for non-spring change to just JSecurityFilter --> <filter-class>org.jsecurity.spring.springjsecurityfilter</filter-class> <init-param> <param-name>config</param-name> <param-value> [filters] jsecurity.loginurl = /s/login jsecurity.unauthorizedurl = /unauthorized.jsp authc.successurl = /s/home [urls] /s/signup=anon /s/manageusers=perms[user:manage] /s/**=authc </param-value> </init-param> </filter>

Spring Integration <bean id="securitymanager" class="org.jsecurity.web.defaultwebsecuritymanager"> <!-- If you have multiple realms, use the 'realms' property instead. --> <property name="realm" ref="samplerealm"/> <!-- To use JSecurity sessions, set the session mode --> <property name="sessionmode" value="jsecurity"/> </bean> <!-- Post processor that automatically invokes init() and destroy() methods --> <bean id="lifecyclebeanpostprocessor" class="org.jsecurity.spring.lifecyclebeanpostprocessor"/>

Samples/Demo Spring-Hibernate Sample App Typical three-tier web app Uses Spring 2.5 and JPA annotations Demonstrates authentication, authorization, logout, annotations, JSP tags, etc. Other samples include standalone and web site/webstart shared sessions

Status Latest release: JSecurity 0.9 1.0 release in the works Packages/docs/code renamed to Ki Assumed Identity (run-as) support Authentication caching More built-in Realms (OpenID, Atlassian Crowd) Other enhancements (tracked in JIRA)

Questions? Website: http://www.jsecurity.org Mailing Lists: jsecurity-user@incubator.apache.org jsecurity-dev@incubator.apache.org