devise_browserid_authenticatable 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Dennis Schubert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ devise_browserid_authenticatable
2
+ ================================
3
+
4
+ Written by Dennis Schubert
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.
9
+
10
+ More infomration about requirements, installation and usage soon.
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "devise_browserid_authenticatable"
3
+ s.summary = "BrowserID/Persona authentication for Devise"
4
+ s.description = "Mozilla BrowserID/Persona authentication module for Devise"
5
+
6
+ s.authors = ["Dennis Schubert"]
7
+ s.email = "gems@schub.io"
8
+ s.homepage = "https://github.com/denschub/devise_browserid_authenticatable"
9
+
10
+ s.files = `git ls-files`.split("\n")
11
+ s.require_paths = ["lib"]
12
+
13
+ s.version = "1.0.0"
14
+
15
+ s.add_dependency "devise", "~> 2.1"
16
+ 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(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
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_browserid_authenticatable
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dennis Schubert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: devise
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
30
+ description: Mozilla BrowserID/Persona authentication module for Devise
31
+ email: gems@schub.io
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - LICENSE
37
+ - README.md
38
+ - devise_browserid_authenticatable.gemspec
39
+ - lib/devise_browserid_authenticatable.rb
40
+ homepage: https://github.com/denschub/devise_browserid_authenticatable
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.24
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: BrowserID/Persona authentication for Devise
64
+ test_files: []