Easy logins for PHP web applications

Post on 08-May-2015

810 views 1 download

description

Users hate picking and having to remember them. Developers hate dealing with and storing them. Why are we still using passwords again? Surely there is a better way to log into websites. This talk will introduce the technology behind Persona and the BrowserID protocol. Mozilla intends to solve the password problem on the web with a federated cross-browser system that is intensely focused on user experience and privacy. We may not be able to get rid of all passwords, after all, you probably don't want to be subjected to a fingerprint check before leaving a comment on someone's blog, but we can eliminate site-specific passwords and replace them with something better: a decentralized system that's under the control of users, not a for-profit gatekeeper. It's just four easy steps to add it to your site from scratch and there are already plugins for Drupal, CakePHP, Joomla, SPIP, Symfony2, Wordpress and PHPMyBB.

Transcript of Easy logins for PHP web applications

François Marier – @fmarier

Easy logins forPHP web applications

passwords

problem #1:

passwords are hard to secure

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

bcrypt / scrypt / pbkdf2

per-user salt

site secret

password & lockout policies

secure recovery

20132013

passwordpassword

guidelines

guidelines

passwords are hard to secure

they are a liability

ALTER TABLE userDROP COLUMN password;

problem #2:

passwords are hard to remember

pick an easy password

pick an easy password

use it everywhere

passwords are hard to remember

they need to be reset

controlemail

account

controlall

accounts=

what other login solution are you using?

“People want a littledating before marriage.”

Eric Vishria – Rockmelt

decentralised

myid.com/u/francois

privacy®

existing login systemsare not good enough

ideal web-wide identity system

● decentralised● simple● cross-browser

ideal web-wide identity system

● decentralised● simple● cross-browser

ideal web-wide identity system

● decentralised● simple

cross-browser

ideal web-wide identity system

what if it were a standardpart of the web browser?

how does it work?

fmarier@gmail.com

why email addresses?

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

why email addresses?

already federated

people know their email

natural association between person & email

easy to have separate identities

most sites need a way to contact users

no lock-in

fmarier@gmail.com

demo #1:

http://www.voo.st/

fmariertest@eyedee.me

Persona is already adecentralised system

decentralisation is the answer, but it's not

a product adoption strategy

we can't wait for all domainsto adopt Persona

we can't wait for all domainsto adopt Persona

solution: a temporarycentralised fallback

demo #2:

http://sloblog.io/

fmariertest@aol.com

Persona already workswith all email domains

identity bridging

demo #3:

http://www.reasonwell.com/

fmariertest@yahoo.com

Persona supportsall modern browsers

>= 8

Persona is decentralised,simple and cross-browser

it's simple for users, but is it also

simple for developers?

<script src=”https://login.persona.org/include.js”></script></body></html>

navigator.id.watch({ loggedInEmail: “francois@mozilla.com”, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { // do something } ); }, onlogout: function () { window.location = '/logout'; }});

navigator.id.watch({ loggedInUser: “francois@mozilla.com”, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { // do something } ); }, onlogout: function () { window.location = '/logout'; }});

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { // do something } ); }, onlogout: function () { window.location = '/logout'; }});

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { // do something } ); }, onlogout: function () { window.location = '/logout'; }});

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { window.location = '/'; } ); }, onlogout: function () { window.location = '/logout'; }});

navigator.id.request()

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { window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RkMTc1ZjhlYmY2YWYzOTdkNjllMTEwYjk2YWZiMTdjN2EwMzI1OTMyOWU0ODI5YjBkMDNiYmM3ODk2YjE1YjRhZGU1M2UxMzA4NThjYzM0ZDk2MjY5YWE4OTA0MWY0MDkxMzZjNzI0MmEzODg5NWM5ZDViY2NhZDRmMzg5YWYxZDdhNGJkMTM5OGJkMDcyZGZmYTg5NjIzMzM5N2EifSwicHJpbmNpcGFsIjp7ImVtYWlsIjoiZm9vQG1vY2tteWlkLmNvbSJ9LCJpYXQiOjEzNzY1MzY0NjM1MTgsImV4cCI6MTM3NjU0MDA2MzUxOCwiaXNzIjoibW9ja215aWQuY29tIn0.IeUR0_3ayAZkdNSXjF4aaCwSHnHa4X1lzrjX-qkNcPIbXx1hmQQPwg~eyJhbGciOiJEUzEyOCJ9.eyJleHAiOjEzNzY1MzY3MDc2MzUsImF1ZCI6Imh0dHA6Ly9sb2NhbGhvc3QifQ.NJ8H1qZcWXbXfPJSdgB_mORHQ442ZkY0XYfdQsZZsIjooG7k7qWyVw

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { window.location = '/home'; } ); }, onlogout: function () { window.location = '/logout'; }});

require_once('Auth/BrowserID.php');

$verifier = new Auth_BrowserID('http://123done.org');$result = $verifier->verifyAssertion($_POST['assertion']);

object(stdClass)#2 (5) { ["status"]=> string(4) "okay" ["audience"]=> string(19) "http://123done.org" ["expires"]=> int(1376282614825) ["issuer"]=> string(17) "login.mozilla.org" ["email"]=> string(20) "francois@mozilla.com"}

require_once('Auth/BrowserID.php');

$verifier = new Auth_BrowserID('http://123done.org');$result = $verifier->verifyAssertion($_POST['assertion']);

if ($result->status === 'okay') { echo "Hi " . $result->email;} else { echo "Error: " . $result->reason;}

object(stdClass)#2 (2) { ["status"]=> string(6) "failed" ["reason"]=> string(21) "assertion has expired"}

require_once('Auth/BrowserID.php');

$verifier = new Auth_BrowserID('http://123done.org');$result = $verifier->verifyAssertion($_POST['assertion']);

if ($result->status === 'okay') { echo "Hi " . $result->email;} else { echo "Error: " . $result->reason;}

navigator.id.logout()

navigator.id.watch({ loggedInUser: null, onlogin: function (assertion) { $.post('/login', {assertion: assertion}, function (data) { window.location = '/home'; } ); }, onlogout: function () { window.location = '/logout'; }});

1. load javascript library

1. load javascript library

2. setup login & logout callbacks

1. load javascript library

2. setup login & logout callbacks

3. add login and logout buttons

1. load javascript library

2. setup login & logout callbacks

3. add login and logout buttons

4. verify proof of ownership

1. load javascript library

2. setup login & logout callbacks

3. add login and logout buttons

4. verify proof of ownership

no API keyneeded

you can add support forPersona in four easy steps

one simple request

building a new site:default to Persona

working on an existing site/app:add support for Persona

before

after

after

navigator.id.request()

ALTER TABLE userDROP COLUMN password;

To learn more about Persona:

https://login.persona.org/http://identity.mozilla.com/

https://developer.mozilla.org/docs/Persona/Why_Personahttps://developer.mozilla.org/docs/Persona/Quick_Setup

https://github.com/mozilla/browserid-cookbookhttps://developer.mozilla.org/docs/Persona/Libraries_and_plugins

http://123done.org/https://wiki.mozilla.org/Identity#Get_Involved

@fmarier http://fmarier.org

identity provider API

https://eyedee.me/.well-known/browserid:

{ "public-key": { "algorithm":"RS", "n":"8606...", "e":"65537" }, "authentication": "/browserid/sign_in.html", "provisioning": "/browserid/provision.html"}

https://eyedee.me/.well-known/browserid:

{ "public-key": { "algorithm":"RS", "n":"8606...", "e":"65537" }, "authentication": "/browserid/sign_in.html", "provisioning": "/browserid/provision.html"}

identity provider API

https://eyedee.me/.well-known/browserid:

{ "public-key": { "algorithm":"RS", "n":"8606...", "e":"65537" }, "authentication": "/browserid/sign_in.html", "provisioning": "/browserid/provision.html"}

identity provider API

https://eyedee.me/.well-known/browserid:

{ "public-key": { "algorithm":"RS", "n":"8606...", "e":"65537" }, "authentication": "/browserid/sign_in.html", "provisioning": "/browserid/provision.html"}

identity provider API

https://eyedee.me/.well-known/browserid:

{ "public-key": { "algorithm":"RS", "n":"8606...", "e":"65537" }, "authentication": "/browserid/sign_in.html", "provisioning": "/browserid/provision.html"}

identity provider API

identity provider API

1. check for your /.well-known/browserid

2. try the provisioning endpoint

3. show the authentication page

4. call the provisioning endpoint again

identity provider API

1. check for your /.well-known/browserid

2. try the provisioning endpoint

3. show the authentication page

4. call the provisioning endpoint again

identity provider API

1. check for your /.well-known/browserid

2. try the provisioning endpoint

3. show the authentication page

4. call the provisioning endpoint again

identity provider API

1. check for your /.well-known/browserid

2. try the provisioning endpoint

3. show the authentication page

4. call the provisioning endpoint again

© 2013 François Marier <francois@mozilla.com>This work is licensed under aCreative Commons Attribution-ShareAlike 3.0 New Zealand License.

Hotel doorman: https://secure.flickr.com/photos/wildlife_encounters/8024166802/

Top 500 passwords: http://xato.net/passwords/more-top-worst-passwords/

Parchment: https://secure.flickr.com/photos/27613359@N03/6750396225/

Uncle Sam: https://secure.flickr.com/photos/donkeyhotey/5666065982/

Restaurant dinner: https://secure.flickr.com/photos/yourdon/3977084094/

Stop sign: https://secure.flickr.com/photos/artbystevejohnson/6673406227/

Photo credits: