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 +1 -0
- data/devise_browserid_authenticatable.gemspec +1 -1
- data/lib/devise_browserid_authenticatable.rb +2 -44
- data/lib/devise_browserid_authenticatable/railtie.rb +9 -0
- data/lib/devise_browserid_authenticatable/strategy.rb +44 -0
- data/lib/devise_browserid_authenticatable/view_helpers.rb +11 -0
- metadata +6 -2
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea/
|
@@ -1,44 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
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,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
|
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.
|
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-
|
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:
|