devise-stormpath 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ Gemfile.lock
3
+ pkg/*
4
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Denis Grankin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ Devise Stormpath authentication
2
+ ===========================
3
+
4
+ Usage
5
+ -----
6
+ In the Gemfile for your application:
7
+
8
+ gem "devise-stormpath"
9
+
10
+ In devise model:
11
+
12
+ devise :stormpath_authenticatable
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "devise/stormpath/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'devise-stormpath'
6
+ s.version = Devise::Stormpath::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.summary = 'Devise extension to allow authentication via Stormpath'
9
+ s.email = 'liquidautumn@gmail.com'
10
+ s.homepage = 'https://github.com/liquidautumn/devise-stormpath'
11
+ s.description = s.summary
12
+ s.author = 'Denis Grankin'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency('devise')
20
+ s.add_dependency('stormpath-rails')
21
+
22
+ s.add_development_dependency('rake')
23
+ end
@@ -0,0 +1,27 @@
1
+ require 'devise/stormpath/strategy'
2
+ require 'stormpath-rails'
3
+
4
+ module Devise
5
+ module Models
6
+ module StormpathAuthenticatable
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ attr_accessor :password_confirmation, :password
11
+ attr_reader :current_password
12
+ end
13
+
14
+ module ClassMethods
15
+ def authenticate_with_stormpath(attributes={})
16
+ login = (self.case_insensitive_keys || []).include?(:username) ? attributes[:username].downcase : attributes[:username]
17
+ begin
18
+ account = ::Stormpath::Rails::Client.authenticate_account(login, attributes[:password])
19
+ return self.where(stormpath_url: account.get_href).first
20
+ rescue ResourceError => error
21
+ return nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'devise/strategies/authenticatable'
2
+
3
+ module Devise
4
+ module Strategies
5
+ class StormpathAuthenticatable < Authenticatable
6
+ def authenticate!
7
+ resource = valid_password? && mapping.to.authenticate_with_stormpath(params[scope])
8
+ return success!(resource) if resource && validate(resource)
9
+ fail(:invalid)
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ Warden::Strategies.add(:stormpath_authenticatable, Devise::Strategies::StormpathAuthenticatable)
@@ -0,0 +1,5 @@
1
+ module Devise
2
+ module Stormpath
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'devise'
2
+
3
+ Devise.add_module(:stormpath_authenticatable,
4
+ :route => :session, :strategy => true, :controller => :sessions, :model => 'devise/stormpath/model')
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise-stormpath
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Denis Grankin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-25 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: '0'
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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: stormpath-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Devise extension to allow authentication via Stormpath
63
+ email: liquidautumn@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - .gitignore
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - devise-stormpath.gemspec
74
+ - lib/devise-stormpath.rb
75
+ - lib/devise/stormpath/model.rb
76
+ - lib/devise/stormpath/strategy.rb
77
+ - lib/devise/stormpath/version.rb
78
+ homepage: https://github.com/liquidautumn/devise-stormpath
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
91
+ - 0
92
+ hash: -1340532585845466111
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -1340532585845466111
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.24
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Devise extension to allow authentication via Stormpath
108
+ test_files: []