devise_browserid_authenticatable 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,8 +3,77 @@ devise_browserid_authenticatable
3
3
 
4
4
  Written by Dennis Schubert
5
5
 
6
- devise_browserid_authenticatable is [BrowserID/Persona](https://persona.org) authentication support for
7
- [Devise](http://github.com/plataformatec/devise) applications. I created this little gem because there
8
- was nothing suitable.
6
+ devise_browserid_authenticatable is a module to add [BrowserID/Persona](https://persona.org)
7
+ authentication support tp [Devise](http://github.com/plataformatec/devise) applications.
9
8
 
10
- More infomration about requirements, installation and usage soon.
9
+ The warden strategy was written for use in Rails 3.1 and Devise 2 application, but they should
10
+ work in other configurations, too.
11
+
12
+ Contributions are welcome.
13
+
14
+ Installation
15
+ ------------
16
+
17
+ To install the gem, just add a
18
+
19
+ gem "devise_browserid_authenticatable"
20
+
21
+ to your Gemfile and run ```bundle install```.
22
+
23
+ To enable the warden strategy, add the following lines to ```config/initializers/devise.rb```:
24
+
25
+ config.warden do |manager|
26
+ manager.default_strategies(:scope => :user).unshift :browserid_authenticatable
27
+ end
28
+
29
+ Using the 'Sign in with persona' button
30
+ ---------------------------------------
31
+
32
+ There is a view helper called ```browserid_js_tag``` to include the BrowserID javascript
33
+ file matching the current environment (development or production). To use it, simply add
34
+
35
+ <%= browserid_js_tag %>
36
+
37
+ to your application layout inside the header.
38
+
39
+ Next you have to find and download a matching button for your application. There are some nice
40
+ buttons (even CSS-only buttons) available, check out [the MDN page](https://developer.mozilla.org/en-US/docs/persona/branding)
41
+ to find one.
42
+
43
+ I like to wrap a link around the image tag so your template could look like
44
+
45
+ <%= link_to (image_tag "persona-button.png", :class => "persona-login-button"), '#' %>
46
+
47
+
48
+ Next you need to add some JavaScript to do the actual sign in process. The JavaScript could look
49
+ like this (you will find an explanation below the code):
50
+
51
+ $(".persona-login-button").click(function(e) {
52
+ e.preventDefault();
53
+
54
+ navigator.id.get(function(assertion) {
55
+ if (assertion) {
56
+ $.ajax({
57
+ url: '/users/sign_in',
58
+ type: "POST",
59
+ dataType: "json",
60
+ cache: false,
61
+ data: {
62
+ "assertion": assertion
63
+ },
64
+ success: function(data, status) {
65
+ window.location.href = '/';
66
+ },
67
+ });
68
+ }
69
+ });
70
+ });
71
+
72
+
73
+ The JavaScript snippet is calling the [navigator.id.get-function](https://developer.mozilla.org/en-US/docs/DOM/navigator.id.get)
74
+ when the user clicked on the sign in button to get an assertion from BrowserID. Check out the linked MDN page
75
+ for information about how to add terms of service and privacy policies if you want to. The callback
76
+ function posts the assertion asynchronous to the Rails application (the sign_in-path) to check it. When the
77
+ check was successful, the script will redirect the user to your application root path.
78
+
79
+ Feel free to add error handling.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "devise_browserid_authenticatable"
3
- s.summary = "BrowserID/Persona authentication for Devise"
4
- s.description = "Mozilla BrowserID/Persona authentication module for Devise"
3
+ s.summary = "BrowserID/Persona authentication for Devise 2+"
4
+ s.description = "Mozilla BrowserID/Persona authentication module that works with Rails 3.1+ and Devise 2.1+"
5
5
 
6
6
  s.authors = ["Dennis Schubert"]
7
7
  s.email = "gems@schub.io"
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.require_paths = ["lib"]
12
12
 
13
- s.version = "1.1.0"
13
+ s.version = "1.1.1"
14
14
 
15
15
  s.add_dependency "devise", "~> 2.1"
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_browserid_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,7 +27,8 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '2.1'
30
- description: Mozilla BrowserID/Persona authentication module for Devise
30
+ description: Mozilla BrowserID/Persona authentication module that works with Rails
31
+ 3.1+ and Devise 2.1+
31
32
  email: gems@schub.io
32
33
  executables: []
33
34
  extensions: []
@@ -64,5 +65,5 @@ rubyforge_project:
64
65
  rubygems_version: 1.8.24
65
66
  signing_key:
66
67
  specification_version: 3
67
- summary: BrowserID/Persona authentication for Devise
68
+ summary: BrowserID/Persona authentication for Devise 2+
68
69
  test_files: []