devise_browserid_authenticatable 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .idea/
@@ -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.0.0"
13
+ s.version = "1.1.0"
14
14
 
15
15
  s.add_dependency "devise", "~> 2.1"
16
16
  end
@@ -1,44 +1,2 @@
1
- require 'devise/strategies/base'
2
- require 'net/https'
3
-
4
- class Devise::Strategies::BrowseridAuthenticatable < Devise::Strategies::Authenticatable
5
- def valid?
6
- unless params[:assertion]
7
- return false
8
- end
9
-
10
- http = Net::HTTP.new(self.browserid_url, 443)
11
- http.use_ssl = true
12
-
13
- verification_request = Net::HTTP::Post.new("/verify")
14
- verification_request.set_form_data(assertion: params[:assertion], audience: request.host_with_port)
15
-
16
- response = http.request(verification_request)
17
- @asserted = JSON.parse(response.body)
18
-
19
- (@asserted["status"] == "okay") and (@asserted["audience"] == request.host_with_port)
20
- end
21
-
22
- def authenticate!
23
- u = mapping.to.find_by_email(@asserted["email"])
24
-
25
- unless u
26
- password = Devise.friendly_token
27
- u = mapping.to.create(:email => @asserted["email"], :password => password, :password_confirmation => password)
28
- u.skip_confirmation!
29
- u.save!
30
- end
31
-
32
- success!(u)
33
- end
34
-
35
- def browserid_url
36
- if Rails.env.production?
37
- "browserid.org"
38
- else
39
- "dev.diresworb.org"
40
- end
41
- end
42
- end
43
-
44
- Warden::Strategies.add :browserid_authenticatable, Devise::Strategies::BrowseridAuthenticatable
1
+ require "devise_browserid_authenticatable/strategy"
2
+ require "devise_browserid_authenticatable/railtie"
@@ -0,0 +1,9 @@
1
+ require "devise_browserid_authenticatable/view_helpers"
2
+
3
+ module BrowserId
4
+ class Railtie < Rails::Railtie
5
+ initializer "browser_id.view_helpers" do
6
+ ActionView::Base.send :include, ViewHelpers
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ require 'devise/strategies/base'
2
+ require 'net/https'
3
+
4
+ class Devise::Strategies::BrowseridAuthenticatable < Devise::Strategies::Authenticatable
5
+ def valid?
6
+ unless params[:assertion]
7
+ return false
8
+ end
9
+
10
+ http = Net::HTTP.new(Devise::Strategies::BrowseridAuthenticatable.browserid_url, 443)
11
+ http.use_ssl = true
12
+
13
+ verification_request = Net::HTTP::Post.new("/verify")
14
+ verification_request.set_form_data(assertion: params[:assertion], audience: request.host_with_port)
15
+
16
+ response = http.request(verification_request)
17
+ @asserted = JSON.parse(response.body)
18
+
19
+ (@asserted["status"] == "okay") and (@asserted["audience"] == request.host_with_port)
20
+ end
21
+
22
+ def authenticate!
23
+ u = mapping.to.find_by_email(@asserted["email"])
24
+
25
+ unless u
26
+ password = Devise.friendly_token
27
+ u = mapping.to.create(:email => @asserted["email"], :password => password, :password_confirmation => password)
28
+ u.skip_confirmation!
29
+ u.save!
30
+ end
31
+
32
+ success!(u)
33
+ end
34
+
35
+ def self.browserid_url
36
+ if Rails.env.production?
37
+ "browserid.org"
38
+ else
39
+ "dev.diresworb.org"
40
+ end
41
+ end
42
+ end
43
+
44
+ Warden::Strategies.add :browserid_authenticatable, Devise::Strategies::BrowseridAuthenticatable
@@ -0,0 +1,11 @@
1
+ module BrowserId
2
+ module ViewHelpers
3
+ def browserid_js_tag
4
+ javascript_include_tag(include_js_url)
5
+ end
6
+
7
+ def include_js_url
8
+ "https://#{Devise::Strategies::BrowseridAuthenticatable.browserid_url}/include.js"
9
+ end
10
+ end
11
+ 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.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-18 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -33,10 +33,14 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - .gitignore
36
37
  - LICENSE
37
38
  - README.md
38
39
  - devise_browserid_authenticatable.gemspec
39
40
  - lib/devise_browserid_authenticatable.rb
41
+ - lib/devise_browserid_authenticatable/railtie.rb
42
+ - lib/devise_browserid_authenticatable/strategy.rb
43
+ - lib/devise_browserid_authenticatable/view_helpers.rb
40
44
  homepage: https://github.com/denschub/devise_browserid_authenticatable
41
45
  licenses: []
42
46
  post_install_message: