How I Built an Access Management System Using Apache Directory - - PowerPoint PPT Presentation

how i built an access management
SMART_READER_LITE
LIVE PREVIEW

How I Built an Access Management System Using Apache Directory - - PowerPoint PPT Presentation

How I Built an Access Management System Using Apache Directory Fortress Shawn McKinney Nov 18, 2016 ApacheCon EU, Seville Session Objectives Learn about some access management specifications Take an unflinching look at an open source


slide-1
SLIDE 1

How I Built an Access Management System Using Apache Directory Fortress

Shawn McKinney Nov 18, 2016 ApacheCon EU, Seville

slide-2
SLIDE 2

Session Objectives

 Learn about some access management specifications  Take an unflinching look at an open source project named Apache Directory Fortress

2 ApacheCon EU, Seville 2016

slide-3
SLIDE 3

Introductions

Shawn McKinney

  • Software Architect
  • PMC Apache Directory Project
  • Engineering Team

3

slide-4
SLIDE 4

Agenda

We’ve got options:

  • 1. What it does (specs & requirements)
  • 2. How it works (design)
  • 3. How it built (implementation)
  • 4. What can it do (demos)

ApacheCon EU, Seville 2016 4

Pi Pick k any three

slide-5
SLIDE 5

Demo Menu

1. Learn about some

– Basic integration - RBAC0 – Intermediate - RBAC1 – Advanced - RBAC2 & 3

2. Testing on

– Fortress Web – “ ” Rest – “ ” Console – “ ” Command Line Interface

3. Have fun with

– Multi-tenancy & / or Benchmarking

ApacheCon EU, Seville 2016 5

  • wicket-sam

ample

  • role-engi

ginee eeri ring-sam ample

  • apache-fortre

tress-dem emo

  • manual or selenium
  • junit
  • ad

ad-hoc

  • sys-admin stuff
  • setting

g up, running, g, verifyi ying

slide-6
SLIDE 6

Cut to the Chase

The recipe for any successful technology project: Mix well:

  • Well defined set of functional specifications
  • Understanding of the non-functional

requirements

  • Usage of common platform elements
  • Practice accepted development methodologies

ApacheCon EU, Seville 2016 6

slide-7
SLIDE 7

Specs & Requirements

Image from: http://www.cockpitseeker.com/aircraft/

7 ApacheCon EU, Seville 2016

What do we we Build?

slide-8
SLIDE 8

System Requirements

  • Policy Enforcement APIs – Works on multiple platforms
  • Authentication – Works within various protocols, i.e.

SAML, OpenID Connect

  • Authorization – Fine-grained and standards-based
  • Audit Trail – Centralized and queryable
  • Administration – Manage policy lifecycle
  • Service-based SLA – Security, performance, and

reliability

ApacheCon EU, Seville 2016 8

slide-9
SLIDE 9

Why Use Functional Specifications?

  • Don’t have to (repeatedly) explain yourself.
  • Saves the trouble (and risk) of deciding what.
  • Instead focus on how.
  • Satisfies req’s didn’t know about (yet).

ApacheCon EU, Seville 2016 9

slide-10
SLIDE 10

Which Functional Specifications

  • Protocols Must Be Standards-Based:

– Role-Based Access Control - ANSI INCITS 359 – Attribute-Based Access Control (ABAC) – IETF Password Policies (Draft) – ARBAC02 Delegated Administration Model

10 ApacheCon EU, Seville 2016

slide-11
SLIDE 11

Role-Based Access Control (RBAC)

11 ApacheCon EU, Seville 2016

slide-12
SLIDE 12

Role-Based Access Control (RBAC)

  • RBAC0

– Users, Roles, Perms, Sessions

  • RBAC1

– Hierarchical Roles

  • RBAC2

– Static Separation of Duties (SSD)

  • RBAC3

– Dynamic Separation of Duties (DSD)

http://csrc.nist.gov/groups/SNS/rbac/

12 ApacheCon EU, Seville 2016

ANSI I INCITS TS 359

slide-13
SLIDE 13

Static Separation of Duty Use Case

Set Name Role Name Type Cardinality Activities Football Static 3 Band Debate

13 ApacheCon EU, Seville 2016

(at t most t two)

slide-14
SLIDE 14

Dynamic Separation of Duty Use Case

Set Name Role Name Type Cardinality Sat Nite Date Dynamic 2 Camping Game

14 ApacheCon EU, Seville 2016

(at t most t one)

slide-15
SLIDE 15

Other SoD Use Cases

ApacheCon EU, Seville 2016 15

Many possibilities apply to financial, government, health care, education and business use cases.

slide-16
SLIDE 16

RBAC Functional Model

Z-not

  • tation

tion

16

slide-17
SLIDE 17

ANSI RBAC Functional Model

Three standard interfaces:

  • 1. Administrative – CRUD
  • 2. Review – policy interrogation
  • 3. System – policy enforcement

17 ApacheCon EU, Seville 2016

slide-18
SLIDE 18

Admin RBAC

public interface AdminMgr { User addUser( User user ); void deleteUser( User user ); Role addRole( Role role ); void deleteRole( Role role ); void assignUser( UserRole uRole ); void deassignUser( UserRole uRole ); Permission addPermission( Permission perm ); void deletePermission( Permission perm ); void grantPermission( Permission perm, Role role ); void addAscendant( Role childRole, Role parentRole);

void addDescendant(Role parentRole, Role childRole); void addDsdRoleMember(SDSet dsdSet, Role role); void addInheritance(Role parentRole, Role childRole) …

Link to AdminMgr javadoc Link to INCITS 359 spec

Fortres ress Admin APIs map to the INCITS ITS 359 specs cs

http://git-wip-us.apache.org/repos/asf/directory-fortress-core.git

18

slide-19
SLIDE 19

Review RBAC

public interface ReviewMgr { Permission readPermission( Permission permission ); List<Permission> findPermissions( Permission permission ); User readUser( User user ); List<User> findUsers( OrgUnit ou ); List<User> assignedUsers( Role role ); Set<String> authorizedRoles( User user ); List<Permission> rolePermissions( Role role ); List<Permission> userPermissions( User user ); Set<String> authorizedPermissionUsers(Permission perm); SDSet dsdRoleSet(SDSet set); Set<String> dsdRoleSetRoles(SDSet dsd);

List<SDSet> dsdRoleSets(Role role);

SDSet ssdRoleSet(SDSet set); Set<String> ssdRoleSetRoles(SDSet dsd); List<SDSet> ssdRoleSets(Role role);

List<Role> findRoles(String searchVal);

Link to ReviewMgr javadoc Link to INCITS 359 spec

Fortres ress Review ew APIs map to the INCIT ITS S 359 specs cs

http://git-wip-us.apache.org/repos/asf/directory-fortress-core.git

slide-20
SLIDE 20

System RBAC

public interface AccessMgr { Session createSession( User user, boolean isTrusted ); List<Permission> sessionPermissions( Session session ); Set<String> authorizedRoles( Session session ); void addActiveRole( Session session, UserRole role ); void dropActiveRole( Session session, UserRole role ); User getUser( Session session ); boolean checkAccess( Session session, Permission perm); }

Link to AccessMgr javadoc Link to INCITS 359 spec

Fortres ress AccessMgr Mgr APIs map to the INCIT ITS S 359 specs cs

http://git-wip-us.apache.org/repos/asf/directory-fortress-core.git

slide-21
SLIDE 21

Administration Requirements

  • Decentralize and distribute administrative

capabilities widely

  • Tight restrictions administrators
  • RBAC system to control the RBAC system

21 ApacheCon EU, Seville 2016

slide-22
SLIDE 22

Admin Role-Based Access Control (ARBAC)

  • Use ARBAC02 Model for

administrative delegation

  • Object Model:

– AdminRoles, AdminPerms, User Orgs, Perm Orgs

  • Functional Model:

– Delegated Administration – Delegated Review – Delegated System Mgr

http://profsandhu.com/journals/tissec/p113-oh.pdf

(APIs Is) (Data) ata)

22 ApacheCon EU, Seville 2016

slide-23
SLIDE 23

Password Policies

1. A configurable limit on failed authentication attempts. 2. A counter to track the number of failed authentication attempts. 3. A time frame in which the limit of consecutive failed authentication attempts. 4. The action to be taken when the limit is reached. 5. An amount of time the account is locked (if it is to be locked) 6. Password expiration. 7. Expiration warning 8. Grace authentications 9. Password history 10. Password minimum age 11. Password minimum length 12. Password Change after Reset 13. Safe Modification of Password

23 ApacheCon EU, Seville 2016

https://tools.ietf.org/html/draft-behera-ldap-password-policy-10

slide-24
SLIDE 24

Other Requirements

  • Audit Trail
  • Lockout Procedures based on Time & Date

ApacheCon EU, Seville 2016 24

slide-25
SLIDE 25

Temporal Constraints

  • Time of Day
  • Day of Week
  • Begin and End

Date

  • Lockout Periods

25

Applies es to User and Role activation tions

slide-26
SLIDE 26

Non-Functional Requirements

  • Fault Tolerant
  • Highly Available
  • Multitenant
  • Highly Performant

System Requirements User Requirements Business Requirements

26 ApacheCon EU, Seville 2016

slide-27
SLIDE 27

Design

Image from: http://flaviendachet.blogspot.com/2011/11/lockheed-sr-71-cutaways.html

27 ApacheCon EU, Seville 2016

How do we Build?

slide-28
SLIDE 28

Design Considerations

  • Many problems to solve:

– Graphing, caching, configuration, persistence, logging, multitenancy, session storage, replication and performance. – Not to mention testing, packaging, documentation and integration. – But, Strive to Keep It Simple Stupid (KISS). – Reuse, don’t reinvent.

Image from: http://wfps.k12.mt.us/teachers/carmichaelg/homework.htm

Reuse, don’t reinvent.

28 ApacheCon EU, Seville 2016

slide-29
SLIDE 29

Data Persistence

  • Choose between Database or LDAP for

Physical Model

  • Need Java framework for data access
  • perations (DAO)

ApacheCon EU, Seville 2016 29

slide-30
SLIDE 30

LDAP Persistence

Satisfies the SLAs:

  • OpenLDAP

– Reads/Search/Bind > 75K/second – Update/Delete > 10K/second – Replication/Highly-Available – Audit Trail – Runs on most platforms – Commercial support options available

30 ApacheCon EU, Seville 2016

slide-31
SLIDE 31

Java LDAP SDK Options

  • JNDI – many problems
  • Netscape / Mozilla LDAP API - obsolete
  • UnboundID Java LDAP API – license concerns
  • Apache LDAP API – just right

ApacheCon EU, Seville 2016 31

slide-32
SLIDE 32

Java LDAP SDK

http://directory.apache.org/api/

32

slide-33
SLIDE 33

Data Structures

RBAC1 Limited Role Hierarchy

  • Single Inheritance
  • Less flexible (not useful)
  • Maps onto the LDAP physical

hier data model just fine

ApacheCon EU, Seville 2016

slide-34
SLIDE 34

Data Structures

RBAC1 General Role Hierarchy

  • Multiple Inheritance
  • More flexible (very usable)
  • A graph doesn’t map onto LDAP

physical model Can’t do this with LDAP

ApacheCon EU, Seville 2016

slide-35
SLIDE 35

Graph Stored Flat in the Tree

  • 1. Roles all at same

e depth th

  • 2. Use a multi-oc
  • ccur

curring g paren ent t attribute ute

slide-36
SLIDE 36

Use Simple Directed Graph

  • http://jgrapht.org/
  • A simple directed graph. A simple

directed graph is a directed graph in which neither multiple edges between any two vertices nor loops are permitted.

  • http://jgrapht.org/javadoc/org/jgrapht

/graph/SimpleDirectedGraph.html

Image from: https://code.google.com/p/fluentdot/wiki/DemoSimpleDirectedGraph

36 ApacheCon EU, Seville 2016

slide-37
SLIDE 37

What About Firewalls?

(LDAPv3 protocol isn’t always allowed)

  • Core API can transmit using either LDAPv3 or

HTTP.

37 ApacheCon EU, Seville 2016

slide-38
SLIDE 38

Audit

  • Use OpenLDAP access log

to record events:

– Authentication – Check Access – Edits – Interrogations

ApacheCon EU, Seville 2016

slide-39
SLIDE 39

Authorization Events

ApacheCon EU, Seville 2016 39

slide-40
SLIDE 40

Administration Events

40

slide-41
SLIDE 41

Authorization API

41

slide-42
SLIDE 42

Configuration

  • Must be capable of retrieving properties from

multiple data locations

– File, directory, system properties, other

  • Can be extended or replaced later if need be

ApacheCon EU, Seville 2016 42

slide-43
SLIDE 43

Use Apache Commons Configuration

  • Application uses

façade

  • Properties may be
  • verwritten at

runtime

slide-44
SLIDE 44

Local and Remote Config

ApacheCon EU, Seville 2016 44

slide-45
SLIDE 45

Data Model Questions

  • How do I represent the physical data model?
  • How do I represent the logical data model?
  • How do I support multitenancy?

ApacheCon EU, Seville 2016 45

slide-46
SLIDE 46

Logical RBAC Model

46

slide-47
SLIDE 47

Logical Model

slide-48
SLIDE 48

Physical RBAC Model

  • Users
  • Roles
  • Permissions
  • Constraints

Segrega regati tion

  • n of Duties

(RBAC2 C2 and 3) Session

  • n (RBAC0

C0) Hierarch chica cal Roles (RBAC1) 1)

48

Perm(RBA (RBAC0 C0)

slide-49
SLIDE 49

Physical Model - Permissions

ApacheCon NA, Vancouver 2016 49

Roles es here is efficient t at runtime

slide-50
SLIDE 50

Multitenancy

Image from: https://directory.apache.org/fortress/user-guide/2.1-fortress-multitenancy.html

50 ApacheCon EU, Seville 2016

slide-51
SLIDE 51

Multitenancy Defined

51 ApacheCon EU, Seville 2016

slide-52
SLIDE 52

Multitenant DIT

ApacheCon EU, Seville 2016 52

slide-53
SLIDE 53

Multitenant Object Model

  • Client’s id is passed in factory initialization
  • Lifecycle of object processes data on behalf of

the client id passed during initialization

– AnyMgr:

  • createInstance(tenantId);

// Instantiate the AccessMgr implementation. AccessMgr accessMgr = AccessMgrFactory.createInstance(“Client123”);

slide-54
SLIDE 54

Web & Realm run in separate contexts

ApacheCon EU, Seville 2016 54

slide-55
SLIDE 55

Caching

Need it for:

  • Hierarchical Roles
  • Static Separation of Duty datasets
  • Dynamic Separation of Duty datasets
  • Organizational Structures

55 ApacheCon EU, Seville 2016

slide-56
SLIDE 56

Use Ehcache

Hide it behind a Facade

56

slide-57
SLIDE 57

Implementation

Image from: http://sploid.gizmodo.com/fascinating-photos-reveal-how-they-built-the-sr-71-blac-1683754944

57 ApacheCon EU, Seville 2016

Intro to Apache e Fortress ress

slide-58
SLIDE 58

Project Guidelines

  • Open Source with permissive license
  • High Quality and Well Maintained
  • Diverse and Active Community
  • Accepted and Transparent Dev Processes
  • Extensible and Supportable for Many Years

58 ApacheCon EU, Seville 2016

slide-59
SLIDE 59

Project Advantages

  • Established Project Methodologies
  • Well defined and understood specifications.
  • Well understood technology base to build on.
  • 3rd time implementing solution of this type.

– Practice makes perfect

59 ApacheCon EU, Seville 2016

slide-60
SLIDE 60

Project Dev Processes

Need a sponsor that provides:

  • Source Code Management
  • Bug Tracking
  • Mailing Lists
  • Build Servers
  • Binary Code Distribution
  • Automated Testing

ApacheCon EU, Seville 2016 60

slide-61
SLIDE 61
slide-62
SLIDE 62

Overview

  • Sub-project of Apache Directory
  • Written in Java
  • Four Components:

– Core – Java APIs + utilities – Realm – Java EE policy enforcement – Web – Administrative UI – Rest – APIs over HTTP interface

62 ApacheCon EU, Seville 2016

slide-63
SLIDE 63

Project History

http://en.wikipedia.org/wiki/Apache_Fortress

slide-64
SLIDE 64

History (cont)

25 Prior Releases

http://mvnrepository.com/artifact/ us.joshuatreesoftware http://mvnrepository.com/artifact/

  • rg.openldap

http://mvnrepository.com/artifact/

  • rg.apache.directory.fortress

1 2 3

64 ApacheCon EU, Seville 2016

slide-65
SLIDE 65

Page Views

ApacheCon EU, Seville 2016 65

1.0-RC42 1.0.0

slide-66
SLIDE 66

Maven Downloads

ApacheCon EU, Seville 2016 66

slide-67
SLIDE 67

67 ApacheCon NA, Vancouver 2016

Open HUB

slide-68
SLIDE 68

Open HUB Details

slide-69
SLIDE 69

Project Releases

https://directory.apache.org/fortress/downloads.html

slide-70
SLIDE 70

Bug Tracking

70

slide-71
SLIDE 71

Static Code Analysis

SonarQube code scans run nightly:

  • Fortress Core: https://analysis.apache.org/dashboard/index/211987
  • Fortress Realm: https://analysis.apache.org/dashboard/index/212344
  • Fortress Web: https://analysis.apache.org/dashboard/index/212576
  • Fortress Rest: https://analysis.apache.org/dashboard/index/212372

71 ApacheCon EU, Seville 2016

Excel celle lent t rule compli lianc ance

slide-72
SLIDE 72

Mailing List

http://mail-archives.apache.org/mod_mbox/directory-fortress/

ApacheCon EU, Seville 2016

slide-73
SLIDE 73

Mailing List

http://mail-archives.apache.org/mod_mbox/directory-fortress/

Low activ ivity ity Crickets ckets chirp rping Med activity ty

slide-74
SLIDE 74

Notability Concerns

ApacheCon EU, Seville 2016 74

slide-75
SLIDE 75

Notability Concerns

ApacheCon EU, Seville 2016 75

slide-76
SLIDE 76

Notability Concerns (cont)

ApacheCon EU, Seville 2016 76

slide-77
SLIDE 77

Components

  • 1. Core – Java SDK
  • 2. Realm – Java EE Policy Enforcement
  • 3. Rest – HTTP Interface
  • 4. Web – HTML Interface

ApacheCon EU, Seville 2016 77

slide-78
SLIDE 78

Core System Architecture

Either er is is Supporte rted Any y directo ctory ry is possib ible le

slide-79
SLIDE 79

Testing

slide-80
SLIDE 80
  • Full test coverage of the APIs
  • Positive and Negative Use Cases
  • No manual testing

Integration Tests

80 ApacheCon EU, Seville 2016

slide-81
SLIDE 81

Automated Testing

https://builds.apache.org/view/All/job/dir-fortress-core-docker-test/org.apache.directory.fortress$fortress-core/

slide-82
SLIDE 82

Core Benchmarks

  • Jmeter tests for various scenarios

– Fortress createSession, checkAccess – Accelerator createSession, checkAccess

82 ApacheCon EU, Seville 2016

slide-83
SLIDE 83

Rest System Architecture

Use any 3rd

rd party

ty rest t lib

  • r Fortr

tress ess Core to connect nect with th Fortr tress ess Rest

Or Or

slide-84
SLIDE 84

Web System Architecture

Opti tion

  • n to use

eith ther er HTTP P or LDAPv3 Pv3 proto tocol

  • l

Or Or

slide-85
SLIDE 85

Demo

ApacheCon EU, Seville 2016 85

slide-86
SLIDE 86

Menu

1. Learn about some

– Basic integration - RBAC0 – Intermediate - RBAC1 – Advanced - RBAC2 & 3

2. Testing on

– Fortress Web – “ ” Rest – “ ” Console – “ ” Command Line Interface

3. Have fun with

– Multi-tenancy & / or Benchmarking

ApacheCon EU, Seville 2016 86

  • wicket-sam

ample

  • role-engi

ginee eeri ring-sam ample

  • apache-fortre

tress-dem emo

  • manual or selenium
  • junit
  • ad

ad-hoc

  • sys-admin stuff
  • setting

g up, running, g, verifyi ying

slide-87
SLIDE 87

Apache Fortress Demo

  • Three Pages and Three Customers
  • One role for every page to customer combo
  • Users may be assigned to one or more roles
  • At most one role may be activated

ApacheCon EU, Seville 2016 87

Pages Customer 123 Customer 456 Customer 789 Page One PAGE1_123 PAGE1_456 PAGE1_789 Page Two PAGE2_123 PAGE2_456 PAGE2_789 Page Three PAGE3_123 PAGE3_456 PAGE3_789

slide-88
SLIDE 88

Demo 1 Usage Policy

  • Both super and power users may access everything.
  • But power users are limited to one role activation at a time.
  • Super users are not restricted.

ApacheCon EU, Seville 2016 88

Super & Power Users Customer 123 Customer 456 Customer 789 Page1 True True True Page2 True True True Page3 True True True

slide-89
SLIDE 89

ApacheCon EU, Seville 2016 89

User123 Customer 123 Customer 456 Customer 789 Page1 True False False Page2 True False False Page3 True False False User1 Customer 123 Customer 456 Customer 789 Page1 True True True Page2 False False False Page3 False False False User1_123 Customer 123 Customer 456 Customer 789 Page1 True False False Page2 False False False Page3 False False False

slide-90
SLIDE 90

Apache Fortress Demo

  • https://github.com/shawnmckinney/apache-

fortress-demo

ApacheCon EU, Seville 2016 90

User-tic-tac-toe Customer 123 Customer 456 Customer 789 Page1 False True True Page2 True False False Page3 True False False

slide-91
SLIDE 91

Demo 2 Role Engineering Sample

ApacheCon EU, Seville 2016

slide-92
SLIDE 92

Demo 2 Role Engineering Sample

  • 1. Java EE Authentication and Authorization
  • 2. Spring Page-level Authorization
  • 3. RBAC Permission Checks

– Links – Buttons

  • 4. Other RBAC Controls

– Dynamic Separation of Duty – Role Switcher

92 ApacheCon EU, Seville 2016

Declarative

slide-93
SLIDE 93

Demo 2 Role Engineering Sample

93 ApacheCon EU, Seville 2016

https://github.com/shawnmckinney/ role-engineering-sample

slide-94
SLIDE 94

Demo 2 Role Engineering Sample

  • Two pages
  • Each has buttons controlled by RBAC Permissions.
  • One Role per page.

94

User to Role Buyers Page Sellers Page ssmith True False jtaylor False True Johndoe* True True * DSD constraint limits user from activating both roles simultaneously.

ApacheCon EU, Seville 2016

slide-95
SLIDE 95

Demo 2 Role Engineering Sample

95

Permission ssmith rtaylor johndoe* 1 Item.bid True False True 2 Item.purchase True False True 3 Item.ship False True True 4 Item.search True True True 5 Account.create True True True 6 Auction.create False True True * DSD constraint limits user from activating both roles simultaneously.

Buyer Seller Both

ApacheCon EU, Seville 2016

slide-96
SLIDE 96

Demo 3 Web Sample

96 ApacheCon EU, Seville 2016

https://github.com/shawnmckinney/ wicket-sample

slide-97
SLIDE 97

ApacheCon EU, Seville 2016

Demo 3 System Architecture

IAAS AS Cloud

97

slide-98
SLIDE 98

Security Layers with Wicket Sample

1.JSSE 2.Java EE Security 3.Web App Framework

ApacheCon EU, Seville 2016 98

Confidenti entiality ty and Itegr grity ty authN N and coarse-grai grained ed authZ fine-gra grained ed authZ

slide-99
SLIDE 99

Add Web Framework Security

add( { @Override protected void onSubmit( ... ) { { // do something here: } else { target.appendJavaScript( ";alert('Unauthorized');" ); } } });

ApacheCon EU, Seville 2016 99

new SecureIndicatingAjaxButton( "Page1", "Add" ) if( checkAccess( customerNumber ) fine-gra

grained ned authori rizat zation n (progra grammatic) tic)

slide-100
SLIDE 100

Demo 3 Web Sample

Wicket Sample Policy File

Github link to

User Page1 Page2 Page3 wsUser1 True False False wsUser2 False True False wsUser3 False False True wsSuperUser True True True

ApacheCon EU, Seville 2016

slide-101
SLIDE 101

Tutorial Links

In Gitub:

  • 1. Wicket Sample:

– https://github.com/shawnmckinney/wicket-sample

  • 2. End-to-End Security Demo:

– https://github.com/shawnmckinney/apache-fortress- demo

101 ApacheCon EU, Seville 2016

slide-102
SLIDE 102

https://iamfortress.net https://symas.com smckinney@symas.com

@shawnmckinney

Twitter: Website: Email: Project: https://directory.apache.org/fortress Blog:

102 ApacheCon EU, Seville 2016