Top Banner
LIONS AND TIGERS AND HANDLING USER CAPABILITIES
87

Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

Jul 19, 2015

Download

Technology

Codemotion
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

LIONS AND TIGERS AND

HANDLING USER CAPABILITIES

Page 2: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014
Page 3: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

HI, I’M TIFFANY@THEOPHANI

Page 4: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

LIONS AND TIGERS ANDHANDLING USER

CAPABILITIES

Page 5: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

(EXAMPLES)

Page 6: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014
Page 7: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ON A HUNT FORWAYS TO APPROACH

USER CAPABILITIES

Page 8: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PART ITHE UX OF USER CAPABILITIES

PART IIIMPLEMENTING USER CAPABILITIES

Page 9: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PART ITHE UX OF

USER CAPABILITIES

Page 10: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GOOD USER CAPABILITY UXHELPS PEOPLE TO

1. AVOID MISTAKES2. UNDERSTAND THEIR CAPABILITIES

3. EASILY MANAGE PERMISSIONS

Page 11: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GOOD USER CAPABILITY UXHELPS PEOPLE TO

1. AVOID MISTAKES

Page 12: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

WHY ADD USERACCESS RESTRICTIONSTO A SYSTEM ANYWAY?

Page 13: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PEOPLE SHOULD NOT BE ABLE TO DO THINGS THAT THEY

ARE NOT ALLOWED DO

Page 14: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PEOPLE SHOULD NOT BE ABLE TO DO THINGS THAT THEY

ARE NOT ALLOWED DO

Page 15: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PEOPLE SHOULD NOT BE ABLE TO DO THINGS THAT THEY

DO NOT NEED TO DO

Page 16: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

THIS IS KNOWN AS THEPRINCIPLE OF

LEAST PRIVILEGE

Page 17: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

Following this principle limits the potential damageof any security breach, whether accidental or malicious.

Page 18: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GOOD USER CAPABILITY UXHELPS PEOPLE TO

2. UNDERSTAND THEIR CAPABILITIES

Page 19: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

INTERACTION DESIGN ASKS

HOW DOES THE USER:affect change?

understand the change?understand what they can change?

Page 20: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

INTERACTION DESIGN ASKS

HOW DOES THE USER:affect change?

understand the change?→ understand what they can change? ←

Page 21: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

YOUR UI MUST COMMUNICATEWHAT THE PERSON CAN DO

Page 22: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

YOUR UI MUST NOT COMMUNICATETHAT THE PERSON CAN DOSOMETHING THEY CAN’T

Page 23: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GOOD USER CAPABILITY UXHELPS PEOPLE TO3. EASILY MANAGE

PERMISSIONS

Page 24: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

FIRST, SOME

DEFINITIONS

Page 25: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

SUBJECT, OBJECT,OPERATION &

PERMISSION, CAPABILITY

Page 26: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

SUBJECT: ACTIVE ENTITY,SUCH A USER OR A PROCESS.

Page 27: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

OBJECT: THINGTHE SUBJECT ACTS UPON.

Page 28: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

OPERATION: ACTIONATTEMPTED BY THE SUBJECT ON THE OBJECT.

Page 29: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PERMISSION: THE RIGHTTO PERFORM THE OPERATION.

Page 30: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

CAPABILITY: ALLOWED OPERATIONTHE SUBJECT HAS PERMISSION

TO PERFORM ON AN OBJECT.

Page 31: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

SUBJECT: PERSONOBJECT: THING

OPERATION: ACTIONPERMISSION: GIVES CAPABILITY

TO A PERSON TO PERFORM AN ACTION ON A THING

Page 32: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ACL , RBACACL: ACCESS CONTROL LIST

RBAC: ROLE-BASED ACCESS CONTROL

Page 33: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ACLACCESS CONTROL

LIST

Page 34: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ACCESS CONTROL LIST

Page 35: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

THE UX OF MAINTAININGAN ACCESS CONTROL LIST

Page 36: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014
Page 37: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

HOW DO YOU KNOWWHICH ACTIONS TO ALLOW

ON WHICH THINGS?

Page 38: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

WHAT IF YOU NEEDED TO UPDATE SUCH A LIST?

Page 39: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GROSS

Page 40: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

NOT GOOD UX

Page 41: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PERMISSIONGROUPS?

Page 42: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ROLE-BASED ACCESS CONTROL TO THE RESCUE!

Page 43: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

RBACROLE-BASED

ACCESS CONTROL

Page 44: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ROLE: JOB FUNCTIONIN AN ORGANIZATION

Page 45: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ROLE: COLLECTION OFCAPABILITIES

Page 46: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PEOPLE CAN HAVEMORE THAN ONE ROLE

Page 47: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

WHEN A ROLE IS CHANGED,PEOPLE’S CAPABILITIES CHANGE TOO

Page 48: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ROLE-BASED ACCESS CONTROLor

ACCESS CONTROL LISTS?

Page 49: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

BAD UX LEADS TO

MISTAKES

Page 50: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

MISTAKESCAN LEAD TO VIOLATIONS OF THE

PRINCIPLE OFLEAST PRIVILEGE

Page 51: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

ROLE-BASED ACCESS CONTROLis better UX than

ACCESS CONTROL LISTS

Page 52: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

RECAP

PART I

Page 53: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

GOOD USER CAPABILITY UXHELPS PEOPLE TO

1. AVOID MISTAKES2. UNDERSTAND THEIR CAPABILITIES

3. EASILY MANAGE PERMISSIONS

Page 54: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

1. AVOID MISTAKESBY FOLLOWING THE

PRINCIPLE OF LEAST PRIVILEGE

Page 55: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PEOPLE SHOULD BE ABLE TO2. UNDERSTAND THEIR

CAPABILITIESBECAUSE YOUR IU COMMUNICATES THEM

Page 56: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

3. EASILY MANAGE PERMISSIONS

BY USING ROLE-BASED ACCESS CONTROL

Page 57: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

PART IIIMPLEMENTING

USER CAPABILITIES

Page 58: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

BUT FIRST, MY

ASSUMPTIONS

Page 59: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

▸ Client-side rendered apps,▸ that use REST APIs to

load and save data asynchronously,▸ and the server can tell the client details

about the authenticated user.

(Though, same ideas can apply to server-side rendered views)

Page 60: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

IMPLEMENTATION CONSTRAINTS:1. ONLY GRANT NECESSARY CAPABILITIES2. UI MUST COMMUNICATE CAPABILITIES

3. USE ROLE-BASED ACCESS CONTROL

Page 61: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

0. THE SERVER-SIDE MUSTENFORCE THE RESTRICTIONS

Page 62: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

THE SERVER-SIDE MUSTENFORCE THE RESTRICTIONS

← OR ELSE STUFF LIKE THIS IS POSSIBLE

Page 63: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

THE SERVER-SIDE MUSTENFORCE THE RESTRICTIONS,

AND THE CLIENT-SIDE MUSTREFLECT THE RESTRICTIONS

Page 64: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// Don’t do this

if ( "Junior Warehouse Clerk" in user.roles || "Warehouse Clerk" in user.roles || "Warehouse Manager" in user.roles ) { // Show "View Orders" button ...}

Page 65: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// Do it like this!

if ( "view orders" in user.capabilities ) {

// Show "View Orders" button ...

}

Page 66: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

$.ajax( url: "/_api/me/capabilities", success: function (response) { user.capabilities = response.capabilities }})

Page 67: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// Checking for one capability

if ( "view orders" in user.capabilities ) {

// Show "View Orders" button ...

}

Page 68: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014
Page 69: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// Checking for more than one capability

if ( "view orders" in user.capabilities || "edit orders" in user.capabilities || "manage customers" in user.capabilities ) { // Show drop down menu icon ...}

Page 70: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

[ THIS KIND OF ]

CAPABILITY CHECKINGIS ADDITIVE

Page 71: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

can ( user, ["view orders"] )// returns true if user can view orders

can ( user, ["action one", "action two", "action three"] ) // returns true if the user can do any of the actions

Page 72: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

function can (user, requiredCapabilities) { return requiredCapabilities.some(function (capability) { return capability in user.capabilities })}

Page 73: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

if ( can (user, ["do something"]) ) { // ...}

Page 74: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

if ( can (user, ["do action", "do another action"]) ) { // ...}

Page 75: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

WHAT ABOUT“LOGIC-LESS” TEMPLATES?

Page 76: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// in your view codemustache.render(template, { can: user.capabilities, // ...})

<!-- in your mustache template -->{{#can.viewOrders}} <a link=“/orders">View Orders</a>{{/can.viewOrders}}

Page 77: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

<nav> {{#can.viewOrders}} <a link="/orders">View Orders</a> {{/can.viewOrders}} {{#can.createOrders}} <a link="/orders/new">Add Order</a> {{/can.createOrders}}</nav>

Page 78: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

<!-- This doesn’t work -->{{#can.viewOrders}} {{#can.createOrders}} <nav> ... </nav> {{/can.createOrders}}{{/can.viewOrders}}

Page 79: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

// Augment capabilities with view-specific ones

if ( can(user, ["view orders", "create orders"]) ) { user.capabilities.viewMenu = true;}

mustache.render(template, { can: user.capabilities, // ...})

Page 80: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

{{#can.viewMenu}} <nav> ... </nav>{{/can.viewMenu}}

Page 81: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

<!-- Handlebar template containing a “can” block helper -->{{#can "viewOrders editOrder"}} <nav> ... </nav>{{/can}}

// Define the block helper ...function canBlockHelper (requiredCapabilities, options) { // ... return hasSomeCapabilities ? options.fn(this) : ""}// ... and register it as “can”Handlebars.registerHelper("can", canBlockHelper);

Page 82: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

{{#can "viewOrders editOrder"}} <nav> {{#can "viewOrders"}} <a link="/orders">View Orders</a> {{/can}} {{#can "createOrders"}} <a link="/orders/new">Add Order</a> {{/can}} </nav>{{/can}}

Page 83: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

# Use the same kind of “can” per route server-side

get "/_api/orders" can ( user, "view orders" ) do # ... end end

post "/_api/orders" can ( user, "add orders" ) do # ... end end

Page 84: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

IN CONCLUSION …

Page 85: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

IMPLEMENTATION CONSTRAINTS:1. ONLY GRANT NECESSARY CAPABILITIES2. UI MUST COMMUNICATE CAPABILITIES

3. USE ROLE-BASED ACCESS CONTROL

Page 86: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

CONSIDER WHEN IMPLEMENTING:1. ENFORCE IN BOTH SERVER AND CLIENTBUT MAKE THE SERVER THE AUTHORITY

2. CHECK AGAINST CAPABILITIES, NOT ROLES

Page 87: Lions and tigers and handling user capabilities - Tiffany Conroy - Codemotion Milan 2014

THANK YOU!TIFFANY CONROY – @THEOPHANI