devise_bushido_authenticatable 1.0.0.alpha10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -2
- data/Gemfile.lock +50 -103
- data/README.md +62 -57
- data/VERSION +1 -1
- data/devise_bushido_authenticatable.gemspec +103 -0
- data/lib/devise_bushido_authenticatable.rb +8 -0
- data/lib/devise_cas_authenticatable.rb +4 -4
- data/lib/devise_cas_authenticatable/model.rb +4 -3
- data/lib/devise_cas_authenticatable/routes.rb +7 -7
- data/lib/devise_cas_authenticatable/schema.rb +3 -5
- data/lib/devise_cas_authenticatable/strategy.rb +5 -2
- metadata +10 -28
data/Gemfile
CHANGED
@@ -10,8 +10,12 @@ group :development do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem "rails", ">= 3
|
14
|
-
|
13
|
+
gem "rails", ">= 2.3"
|
14
|
+
|
15
|
+
# had to comment this out to use with rails 2.3
|
16
|
+
# gem "rspec-rails", ">= 2.5.0"
|
17
|
+
gem 'rspec'
|
18
|
+
|
15
19
|
gem "mocha"
|
16
20
|
gem "shoulda"
|
17
21
|
gem "sqlite3-ruby"
|
data/Gemfile.lock
CHANGED
@@ -1,118 +1,69 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.2.1)
|
15
|
-
rack-mount (~> 0.6.14)
|
16
|
-
rack-test (~> 0.5.7)
|
17
|
-
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.7)
|
19
|
-
activesupport (= 3.0.7)
|
20
|
-
builder (~> 2.1.2)
|
21
|
-
i18n (~> 0.5.0)
|
22
|
-
activerecord (3.0.7)
|
23
|
-
activemodel (= 3.0.7)
|
24
|
-
activesupport (= 3.0.7)
|
25
|
-
arel (~> 2.0.2)
|
26
|
-
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.7)
|
28
|
-
activemodel (= 3.0.7)
|
29
|
-
activesupport (= 3.0.7)
|
30
|
-
activesupport (3.0.7)
|
4
|
+
actionmailer (2.3.2)
|
5
|
+
actionpack (= 2.3.2)
|
6
|
+
actionpack (2.3.2)
|
7
|
+
activesupport (= 2.3.2)
|
8
|
+
activerecord (2.3.2)
|
9
|
+
activesupport (= 2.3.2)
|
10
|
+
activeresource (2.3.2)
|
11
|
+
activesupport (= 2.3.2)
|
12
|
+
activesupport (2.3.2)
|
13
|
+
addressable (2.2.6)
|
31
14
|
archive-tar-minitar (0.5.2)
|
32
|
-
arel (2.0.9)
|
33
15
|
bcrypt-ruby (2.1.4)
|
34
|
-
|
35
|
-
capybara (0.4.1.1)
|
36
|
-
celerity (>= 0.7.9)
|
37
|
-
culerity (>= 0.2.4)
|
16
|
+
capybara (1.0.0)
|
38
17
|
mime-types (>= 1.16)
|
39
18
|
nokogiri (>= 1.3.3)
|
40
19
|
rack (>= 1.0.0)
|
41
20
|
rack-test (>= 0.5.4)
|
42
|
-
selenium-webdriver (
|
43
|
-
xpath (~> 0.1.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
columnize (0.3.1)
|
48
|
-
configuration (1.2.0)
|
21
|
+
selenium-webdriver (~> 0.2.0)
|
22
|
+
xpath (~> 0.1.4)
|
23
|
+
childprocess (0.2.0)
|
24
|
+
ffi (~> 1.0.6)
|
25
|
+
columnize (0.3.4)
|
49
26
|
crypt-isaac (0.9.1)
|
50
|
-
|
51
|
-
devise (1.3.4)
|
27
|
+
devise (1.4.2)
|
52
28
|
bcrypt-ruby (~> 2.1.2)
|
53
29
|
orm_adapter (~> 0.0.3)
|
54
30
|
warden (~> 1.0.3)
|
55
31
|
diff-lcs (1.1.2)
|
56
|
-
|
57
|
-
abstract (>= 1.0.0)
|
58
|
-
ffi (0.6.3)
|
59
|
-
rake (>= 0.8.7)
|
32
|
+
ffi (1.0.9)
|
60
33
|
git (1.2.5)
|
61
|
-
|
62
|
-
|
63
|
-
bundler (~> 1.0.0)
|
34
|
+
jeweler (1.6.4)
|
35
|
+
bundler (~> 1.0)
|
64
36
|
git (>= 1.2.5)
|
65
37
|
rake
|
66
|
-
json_pure (1.5.
|
67
|
-
launchy (0.
|
68
|
-
|
69
|
-
rake (>= 0.8.1)
|
38
|
+
json_pure (1.5.3)
|
39
|
+
launchy (2.0.5)
|
40
|
+
addressable (~> 2.2.6)
|
70
41
|
linecache (0.43)
|
71
42
|
linecache19 (0.5.12)
|
72
43
|
ruby_core_source (>= 0.1.4)
|
73
|
-
mail (2.2.19)
|
74
|
-
activesupport (>= 2.3.6)
|
75
|
-
i18n (>= 0.4.0)
|
76
|
-
mime-types (~> 1.16)
|
77
|
-
treetop (~> 1.4.8)
|
78
44
|
mime-types (1.16)
|
79
|
-
mocha (0.9.
|
80
|
-
|
81
|
-
nokogiri (1.4.4)
|
45
|
+
mocha (0.9.12)
|
46
|
+
nokogiri (1.5.0)
|
82
47
|
orm_adapter (0.0.5)
|
83
|
-
|
84
|
-
rack (
|
85
|
-
rack-mount (0.6.14)
|
86
|
-
rack (>= 1.0.0)
|
87
|
-
rack-test (0.5.7)
|
48
|
+
rack (1.3.2)
|
49
|
+
rack-test (0.6.1)
|
88
50
|
rack (>= 1.0)
|
89
|
-
rails (3.
|
90
|
-
actionmailer (= 3.
|
91
|
-
actionpack (= 3.
|
92
|
-
activerecord (= 3.
|
93
|
-
activeresource (= 3.
|
94
|
-
activesupport (= 3.
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
rspec (2.5.0)
|
104
|
-
rspec-core (~> 2.5.0)
|
105
|
-
rspec-expectations (~> 2.5.0)
|
106
|
-
rspec-mocks (~> 2.5.0)
|
107
|
-
rspec-core (2.5.2)
|
108
|
-
rspec-expectations (2.5.0)
|
51
|
+
rails (2.3.2)
|
52
|
+
actionmailer (= 2.3.2)
|
53
|
+
actionpack (= 2.3.2)
|
54
|
+
activerecord (= 2.3.2)
|
55
|
+
activeresource (= 2.3.2)
|
56
|
+
activesupport (= 2.3.2)
|
57
|
+
rake (>= 0.8.3)
|
58
|
+
rake (0.9.2)
|
59
|
+
rspec (2.6.0)
|
60
|
+
rspec-core (~> 2.6.0)
|
61
|
+
rspec-expectations (~> 2.6.0)
|
62
|
+
rspec-mocks (~> 2.6.0)
|
63
|
+
rspec-core (2.6.4)
|
64
|
+
rspec-expectations (2.6.0)
|
109
65
|
diff-lcs (~> 1.1.2)
|
110
|
-
rspec-mocks (2.
|
111
|
-
rspec-rails (2.5.0)
|
112
|
-
actionpack (~> 3.0)
|
113
|
-
activesupport (~> 3.0)
|
114
|
-
railties (~> 3.0)
|
115
|
-
rspec (~> 2.5.0)
|
66
|
+
rspec-mocks (2.6.0)
|
116
67
|
ruby-debug (0.10.4)
|
117
68
|
columnize (>= 0.1)
|
118
69
|
ruby-debug-base (~> 0.10.4.0)
|
@@ -129,24 +80,20 @@ GEM
|
|
129
80
|
ruby_core_source (0.1.5)
|
130
81
|
archive-tar-minitar (>= 0.5.2)
|
131
82
|
rubyzip (0.9.4)
|
132
|
-
selenium-webdriver (0.
|
133
|
-
childprocess (
|
134
|
-
ffi (
|
83
|
+
selenium-webdriver (0.2.2)
|
84
|
+
childprocess (>= 0.1.9)
|
85
|
+
ffi (>= 1.0.7)
|
135
86
|
json_pure
|
136
87
|
rubyzip
|
137
88
|
sham_rack (1.3.3)
|
138
89
|
rack
|
139
90
|
shoulda (2.11.3)
|
140
|
-
sqlite3 (1.3.
|
91
|
+
sqlite3 (1.3.4)
|
141
92
|
sqlite3-ruby (1.3.3)
|
142
93
|
sqlite3 (>= 1.3.3)
|
143
|
-
|
144
|
-
treetop (1.4.9)
|
145
|
-
polyglot (>= 0.3.1)
|
146
|
-
tzinfo (0.3.27)
|
147
|
-
warden (1.0.4)
|
94
|
+
warden (1.0.5)
|
148
95
|
rack (>= 1.0)
|
149
|
-
xpath (0.1.
|
96
|
+
xpath (0.1.4)
|
150
97
|
nokogiri (~> 1.3)
|
151
98
|
|
152
99
|
PLATFORMS
|
@@ -160,8 +107,8 @@ DEPENDENCIES
|
|
160
107
|
launchy
|
161
108
|
linecache (= 0.43)
|
162
109
|
mocha
|
163
|
-
rails (>= 3
|
164
|
-
rspec
|
110
|
+
rails (>= 2.3)
|
111
|
+
rspec
|
165
112
|
ruby-debug
|
166
113
|
ruby-debug19
|
167
114
|
sham_rack
|
data/README.md
CHANGED
@@ -1,114 +1,119 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
devise_bushido_authenticatable
|
2
|
+
===============================
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
devise_bushido_authenticatable provides single sign-on support for Bushido applications, that use
|
5
|
+
[Devise](http://github.com/plataformatec/devise) for authentication. It acts as a **replacement for the database_authenticatable option that devise provides**
|
6
|
+
|
7
|
+
For applications running on Bushido, the authentication server provides the following user data:
|
8
|
+
|
9
|
+
* ido_id - a string that is unique to the user
|
10
|
+
* email - user's email address
|
11
|
+
* first_name - user's first name
|
12
|
+
* last_name - user's last name
|
13
|
+
* locale - user's locale
|
6
14
|
|
7
|
-
devise_cas_authenticatable is [CAS](http://www.jasig.org/cas) single sign-on support for
|
8
|
-
[Devise](http://github.com/plataformatec/devise) applications. It acts as a replacement for
|
9
|
-
database_authenticatable. It builds on [rubycas-client](http://github.com/gunark/rubycas-client)
|
10
|
-
and should support just about any conformant CAS server (although I have personally tested it
|
11
|
-
using [rubycas-server](http://github.com/gunark/rubycas-server)).
|
12
15
|
|
13
16
|
Requirements
|
14
17
|
------------
|
15
18
|
|
16
19
|
- Rails 2.3 or 3.0
|
17
20
|
- Devise 1.0 or greater
|
18
|
-
- rubycas-client
|
19
21
|
|
20
22
|
Installation
|
21
23
|
------------
|
22
24
|
|
23
|
-
gem install --pre
|
25
|
+
gem install --pre devise_bushido_authenticatable
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
config.gem 'devise', :version => '~> 1.0.6'
|
28
|
-
config.gem 'devise_cas_authenticatable'
|
29
|
-
|
30
|
-
or Gemfile (Rails 3.0):
|
27
|
+
### Rails 3.x: Add the following to your Gemfile
|
31
28
|
|
32
29
|
gem 'devise'
|
33
|
-
gem '
|
30
|
+
gem 'devise_bushido_authenticatable'
|
34
31
|
|
35
|
-
|
36
|
-
-------
|
32
|
+
This has been tested with 3.1 rc5 too. So feel safe to use it :)
|
37
33
|
|
38
|
-
|
39
|
-
[here](http://github.com/nbudin/devise_cas_example).
|
34
|
+
### Rails 2.3: Add the following in your config/environment.rb
|
40
35
|
|
36
|
+
config.gem 'devise', :version => '~> 1.0.6'
|
37
|
+
config.gem 'devise_bushido_authenticatable'
|
38
|
+
|
39
|
+
|
41
40
|
Setup
|
42
41
|
-----
|
43
42
|
|
44
|
-
|
43
|
+
### 1.) Add the following to your devise model
|
45
44
|
|
46
|
-
devise :
|
45
|
+
devise :bushido_authenticatable
|
47
46
|
|
48
|
-
You can
|
49
|
-
|
47
|
+
You can add other modules like trackable, but **do not use database_authenticatable**. bushido_authenticatable is a replacement for that.
|
48
|
+
|
49
|
+
### 2.) Modify schema migration
|
50
50
|
|
51
|
-
|
51
|
+
Add the field required for the auth to work. For example, if the devise model is called User, add *bushido_authenticatable* to the schema like below.
|
52
52
|
|
53
53
|
create_table :users do |t|
|
54
|
-
t.
|
54
|
+
t.bushido_authenticatable
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
That will add a string field called *ido_id*, which is unique to each Bushido user.
|
58
58
|
|
59
|
-
add_index :users, :username, :unique => true
|
60
59
|
|
61
|
-
|
62
|
-
to tell your app how to talk to your CAS server:
|
60
|
+
### 3.) [OPTIONAL] Add ido_id to be indexed
|
63
61
|
|
64
|
-
|
65
|
-
...
|
66
|
-
config.cas_base_url = "https://cas.myorganization.com"
|
67
|
-
|
68
|
-
# you can override these if you need to, but cas_base_url is usually enough
|
69
|
-
# config.cas_login_url = "https://cas.myorganization.com/login"
|
70
|
-
# config.cas_logout_url = "https://cas.myorganization.com/logout"
|
71
|
-
# config.cas_validate_url = "https://cas.myorganization.com/serviceValidate"
|
72
|
-
|
73
|
-
# By default, devise_cas_authenticatable will create users. If you would rather
|
74
|
-
# require user records to already exist locally before they can authenticate via
|
75
|
-
# CAS, uncomment the following line.
|
76
|
-
# config.cas_create_user = false
|
77
|
-
end
|
62
|
+
add_index :users, :ido_id, :unique => true
|
78
63
|
|
64
|
+
|
79
65
|
Extra attributes
|
80
66
|
----------------
|
81
67
|
|
82
|
-
|
83
|
-
|
84
|
-
|
68
|
+
When the user is authenticated, Bushido passed along the following extra attributes:
|
69
|
+
|
70
|
+
* email - user's email address
|
71
|
+
* first_name - user's first name
|
72
|
+
* last_name - user's last name
|
73
|
+
* locale - user's locale
|
74
|
+
|
75
|
+
If you find any of these attributes useful and want to capture them, add a bushido_extra_attributes method to your User model (or whichever is your devise model). Below is an example that saves the email and the locale of a user.
|
85
76
|
|
86
77
|
class User < ActiveRecord::Base
|
87
|
-
devise :
|
78
|
+
devise :bushido_authenticatable
|
88
79
|
|
89
|
-
def
|
80
|
+
def bushido_extra_attributes(extra_attributes)
|
90
81
|
extra_attributes.each do |name, value|
|
91
82
|
case name.to_sym
|
92
|
-
when :fullname
|
93
|
-
self.fullname = value
|
94
83
|
when :email
|
95
84
|
self.email = value
|
85
|
+
when :locale
|
86
|
+
self.locale = value
|
96
87
|
end
|
97
88
|
end
|
98
89
|
end
|
99
90
|
end
|
100
91
|
|
92
|
+
The example above assumes that you have created fields called "email" and "locale" to save the attributes to. This gem doesn't create that for you. It has to be created manually and are optional.
|
93
|
+
|
94
|
+
__Note that these attributes might change anytime and are hence passed on as extra attributes. If defined, this method is called whenever the user logs into your app (starts a session). So when any of these are changed, your application will be able to capture those.__
|
95
|
+
|
96
|
+
**It is not advisable to use the user's email address to identify the user. Use the ido_id field for that purpose.**
|
97
|
+
|
98
|
+
Credits
|
99
|
+
--------
|
100
|
+
Based on [devise_cas_authenticatable](http://github.com/nbudin/devise_cas_authenticatable) by Nat Budin.
|
101
|
+
|
102
|
+
#### Tweaks by:
|
103
|
+
|
104
|
+
* Sean Grove
|
105
|
+
* Akash Manohar
|
106
|
+
|
107
|
+
[When contributing, add your name above and commit]
|
108
|
+
|
101
109
|
See also
|
102
110
|
--------
|
103
111
|
|
104
|
-
* [CAS](http://www.jasig.org/cas)
|
105
|
-
* [rubycas-server](http://github.com/gunark/rubycas-server)
|
106
|
-
* [rubycas-client](http://github.com/gunark/rubycas-client)
|
107
112
|
* [Devise](http://github.com/plataformatec/devise)
|
108
113
|
* [Warden](http://github.com/hassox/warden)
|
109
114
|
|
115
|
+
|
110
116
|
TODO
|
111
117
|
----
|
112
118
|
|
113
|
-
* Implement CAS single sign-off support (maybe via a Rack middleware?)
|
114
119
|
* Test on non-ActiveRecord ORMs
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0
|
1
|
+
1.0.0
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{devise_bushido_authenticatable}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Akash Manohar J", "Sean Grove", "Didier Lafforgue"]
|
12
|
+
s.date = %q{2011-08-25}
|
13
|
+
s.description = %q{Bushido SSO authentication module for Devise. A slight variant of the excellent work from Nat Budlin on devise_cas_authenticatable.}
|
14
|
+
s.email = %q{s@bushi.do}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".project",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"app/controllers/devise/cas_sessions_controller.rb",
|
26
|
+
"app/views/devise/cas_sessions/new.html.erb",
|
27
|
+
"app/views/devise/cas_sessions/unregistered.html.erb",
|
28
|
+
"devise_bushido_authenticatable.gemspec",
|
29
|
+
"devise_cas_authenticatable.gemspec",
|
30
|
+
"lib/devise_bushido_authenticatable.rb",
|
31
|
+
"lib/devise_cas_authenticatable.rb",
|
32
|
+
"lib/devise_cas_authenticatable/exceptions.rb",
|
33
|
+
"lib/devise_cas_authenticatable/model.rb",
|
34
|
+
"lib/devise_cas_authenticatable/routes.rb",
|
35
|
+
"lib/devise_cas_authenticatable/schema.rb",
|
36
|
+
"lib/devise_cas_authenticatable/strategy.rb",
|
37
|
+
"rails/init.rb",
|
38
|
+
"spec/routes_spec.rb",
|
39
|
+
"spec/scenario/.gitignore",
|
40
|
+
"spec/scenario/app/controllers/application_controller.rb",
|
41
|
+
"spec/scenario/app/controllers/home_controller.rb",
|
42
|
+
"spec/scenario/app/models/user.rb",
|
43
|
+
"spec/scenario/app/views/layouts/application.html.erb",
|
44
|
+
"spec/scenario/config.ru",
|
45
|
+
"spec/scenario/config/application.rb",
|
46
|
+
"spec/scenario/config/boot.rb",
|
47
|
+
"spec/scenario/config/castronaut.yml",
|
48
|
+
"spec/scenario/config/database.yml",
|
49
|
+
"spec/scenario/config/environment.rb",
|
50
|
+
"spec/scenario/config/environments/development.rb",
|
51
|
+
"spec/scenario/config/environments/production.rb",
|
52
|
+
"spec/scenario/config/environments/test.rb",
|
53
|
+
"spec/scenario/config/initializers/backtrace_silencers.rb",
|
54
|
+
"spec/scenario/config/initializers/devise.rb",
|
55
|
+
"spec/scenario/config/initializers/inflections.rb",
|
56
|
+
"spec/scenario/config/initializers/mime_types.rb",
|
57
|
+
"spec/scenario/config/initializers/secret_token.rb",
|
58
|
+
"spec/scenario/config/initializers/session_store.rb",
|
59
|
+
"spec/scenario/config/locales/en.yml",
|
60
|
+
"spec/scenario/config/routes.rb",
|
61
|
+
"spec/scenario/config/rubycas-server.yml",
|
62
|
+
"spec/scenario/db/migrate/20100401102949_create_tables.rb",
|
63
|
+
"spec/scenario/public/.gitkeep",
|
64
|
+
"spec/spec_helper.rb",
|
65
|
+
"spec/strategy_spec.rb",
|
66
|
+
"spec/support/migrations.rb"
|
67
|
+
]
|
68
|
+
s.homepage = %q{http://github.com/bushido/bushido_cas_authenticatable}
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.rubygems_version = %q{1.6.2}
|
71
|
+
s.summary = %q{Bushido SSO authentication module for Devise}
|
72
|
+
|
73
|
+
if s.respond_to? :specification_version then
|
74
|
+
s.specification_version = 3
|
75
|
+
|
76
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
77
|
+
s.add_runtime_dependency(%q<devise>, [">= 0"])
|
78
|
+
s.add_development_dependency(%q<linecache>, ["= 0.43"])
|
79
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
82
|
+
s.add_runtime_dependency(%q<devise>, [">= 1.0.6"])
|
83
|
+
s.add_runtime_dependency(%q<rubycas-client>, [">= 2.2.1"])
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<devise>, [">= 0"])
|
86
|
+
s.add_dependency(%q<linecache>, ["= 0.43"])
|
87
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
88
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
89
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
90
|
+
s.add_dependency(%q<devise>, [">= 1.0.6"])
|
91
|
+
s.add_dependency(%q<rubycas-client>, [">= 2.2.1"])
|
92
|
+
end
|
93
|
+
else
|
94
|
+
s.add_dependency(%q<devise>, [">= 0"])
|
95
|
+
s.add_dependency(%q<linecache>, ["= 0.43"])
|
96
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
97
|
+
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
98
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
99
|
+
s.add_dependency(%q<devise>, [">= 1.0.6"])
|
100
|
+
s.add_dependency(%q<rubycas-client>, [">= 2.2.1"])
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
module Devise
|
22
22
|
# The base URL of the CAS server. For example, http://cas.example.com. Specifying this
|
23
23
|
# is mandatory.
|
24
|
-
@@cas_base_url =
|
24
|
+
@@cas_base_url = "https://auth.bushi.do/cas"
|
25
25
|
|
26
26
|
# The login URL of the CAS server. If undefined, will default based on cas_base_url.
|
27
27
|
@@cas_login_url = nil
|
@@ -38,7 +38,7 @@ module Devise
|
|
38
38
|
|
39
39
|
# The model attribute used for query conditions. Should be the same as
|
40
40
|
# the rubycas-server username_column. :username by default
|
41
|
-
@@cas_username_column = :
|
41
|
+
@@cas_username_column = :ido_id
|
42
42
|
|
43
43
|
# Name of the parameter passed in the logout query
|
44
44
|
@@cas_destination_logout_param_name = nil
|
@@ -86,8 +86,8 @@ module Devise
|
|
86
86
|
|
87
87
|
end
|
88
88
|
|
89
|
-
Devise.add_module(:
|
89
|
+
Devise.add_module(:bushido_authenticatable,
|
90
90
|
:strategy => true,
|
91
91
|
:controller => :cas_sessions,
|
92
|
-
:route => :
|
92
|
+
:route => :bushido_authenticatable,
|
93
93
|
:model => 'devise_cas_authenticatable/model')
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Devise
|
2
2
|
module Models
|
3
3
|
# Extends your User class with support for CAS ticket authentication.
|
4
|
-
module
|
4
|
+
module BushidoAuthenticatable
|
5
5
|
def self.included(base)
|
6
6
|
base.extend ClassMethods
|
7
7
|
|
8
8
|
if defined?(Mongoid)
|
9
9
|
base.class_eval do
|
10
|
-
field :
|
10
|
+
field :ido_id # TODO check with someone who's using Mongoid
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -27,6 +27,7 @@ module Devise
|
|
27
27
|
puts "ticket = #{ticket.inspect}"
|
28
28
|
|
29
29
|
if ticket.is_valid?
|
30
|
+
|
30
31
|
conditions = {::Devise.cas_username_column => ticket.response.user}
|
31
32
|
|
32
33
|
# We don't want to override Devise 1.1's find_for_authentication
|
@@ -42,7 +43,7 @@ module Devise
|
|
42
43
|
|
43
44
|
return nil unless resource
|
44
45
|
|
45
|
-
resource.
|
46
|
+
resource.bushido_extra_attributes(ticket.response.extra_attributes) if resource.respond_to? :bushido_extra_attributes
|
46
47
|
|
47
48
|
# puts "resource.cas_extra_attributes = #{resource.cas_extra_attributes.inspect}"
|
48
49
|
|
@@ -4,7 +4,7 @@ if ActionController::Routing.name =~ /ActionDispatch/
|
|
4
4
|
ActionDispatch::Routing::Mapper.class_eval do
|
5
5
|
protected
|
6
6
|
|
7
|
-
def
|
7
|
+
def devise_bushido_authenticatable(mapping, controllers)
|
8
8
|
# service endpoint for CAS server
|
9
9
|
get "service", :to => "#{controllers[:cas_sessions]}#service", :as => "service"
|
10
10
|
|
@@ -13,18 +13,18 @@ if ActionController::Routing.name =~ /ActionDispatch/
|
|
13
13
|
get :unregistered
|
14
14
|
post :create, :path => mapping.path_names[:sign_in]
|
15
15
|
match :destroy, :path => mapping.path_names[:sign_out], :as => "destroy"
|
16
|
-
end
|
16
|
+
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
else
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
# Rails 2
|
22
22
|
ActionController::Routing::RouteSet::Mapper.class_eval do
|
23
23
|
protected
|
24
|
-
|
25
|
-
def
|
24
|
+
|
25
|
+
def bushido_authenticatable(routes, mapping)
|
26
26
|
routes.with_options(:controller => 'devise/cas_sessions', :name_prefix => nil) do |session|
|
27
|
-
session.send(:"#{mapping.name}_service",
|
27
|
+
session.send(:"#{mapping.name}_service", "/service", :action => 'service', :conditions => {:method => :get})
|
28
28
|
session.send(:"unregistered_#{mapping.name}_session", '/unregistered', :action => "unregistered", :conditions => {:method => :get})
|
29
29
|
session.send(:"new_#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'new', :conditions => {:method => :get})
|
30
30
|
session.send(:"#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'create', :conditions => {:method => :post})
|
@@ -2,13 +2,11 @@ require 'devise/schema'
|
|
2
2
|
|
3
3
|
module Devise
|
4
4
|
module Schema
|
5
|
-
|
6
|
-
# this is just username (String).
|
7
|
-
def cas_authenticatable
|
5
|
+
def bushido_authenticatable
|
8
6
|
if respond_to? :apply_devise_schema
|
9
|
-
apply_devise_schema :
|
7
|
+
apply_devise_schema :ido_id, String
|
10
8
|
else
|
11
|
-
apply_schema :
|
9
|
+
apply_schema :ido_id, String
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -19,7 +19,10 @@ module Devise
|
|
19
19
|
if resource = mapping.to.authenticate_with_cas_ticket(ticket)
|
20
20
|
success!(resource)
|
21
21
|
elsif ticket.is_valid?
|
22
|
-
|
22
|
+
logger.debug "="*30
|
23
|
+
logger.debug ticket.response.user[:ido_id]
|
24
|
+
logger.debug "="*30
|
25
|
+
redirect!(::Devise.cas_unregistered_url(request.url, mapping), :ido_id => ticket.response.user)
|
23
26
|
#fail!("The user #{ticket.response.user} is not registered with this site. Please use a different account.")
|
24
27
|
else
|
25
28
|
fail!(:invalid)
|
@@ -46,4 +49,4 @@ module Devise
|
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
|
-
Warden::Strategies.add(:
|
52
|
+
Warden::Strategies.add(:bushido_authenticatable, Devise::Strategies::CasAuthenticatable)
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_bushido_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 1.0.0
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Akash Manohar J
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2011-
|
15
|
+
date: 2011-08-25 00:00:00 -07:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -110,7 +110,9 @@ files:
|
|
110
110
|
- app/controllers/devise/cas_sessions_controller.rb
|
111
111
|
- app/views/devise/cas_sessions/new.html.erb
|
112
112
|
- app/views/devise/cas_sessions/unregistered.html.erb
|
113
|
+
- devise_bushido_authenticatable.gemspec
|
113
114
|
- devise_cas_authenticatable.gemspec
|
115
|
+
- lib/devise_bushido_authenticatable.rb
|
114
116
|
- lib/devise_cas_authenticatable.rb
|
115
117
|
- lib/devise_cas_authenticatable/exceptions.rb
|
116
118
|
- lib/devise_cas_authenticatable/model.rb
|
@@ -161,16 +163,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
163
|
requirements:
|
162
164
|
- - ">="
|
163
165
|
- !ruby/object:Gem::Version
|
164
|
-
hash:
|
166
|
+
hash: 289950257324360238
|
165
167
|
segments:
|
166
168
|
- 0
|
167
169
|
version: "0"
|
168
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
171
|
none: false
|
170
172
|
requirements:
|
171
|
-
- - "
|
173
|
+
- - ">="
|
172
174
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
175
|
+
version: "0"
|
174
176
|
requirements: []
|
175
177
|
|
176
178
|
rubyforge_project:
|
@@ -178,25 +180,5 @@ rubygems_version: 1.6.2
|
|
178
180
|
signing_key:
|
179
181
|
specification_version: 3
|
180
182
|
summary: Bushido SSO authentication module for Devise
|
181
|
-
test_files:
|
182
|
-
|
183
|
-
- spec/scenario/app/controllers/application_controller.rb
|
184
|
-
- spec/scenario/app/controllers/home_controller.rb
|
185
|
-
- spec/scenario/app/models/user.rb
|
186
|
-
- spec/scenario/config/application.rb
|
187
|
-
- spec/scenario/config/boot.rb
|
188
|
-
- spec/scenario/config/environment.rb
|
189
|
-
- spec/scenario/config/environments/development.rb
|
190
|
-
- spec/scenario/config/environments/production.rb
|
191
|
-
- spec/scenario/config/environments/test.rb
|
192
|
-
- spec/scenario/config/initializers/backtrace_silencers.rb
|
193
|
-
- spec/scenario/config/initializers/devise.rb
|
194
|
-
- spec/scenario/config/initializers/inflections.rb
|
195
|
-
- spec/scenario/config/initializers/mime_types.rb
|
196
|
-
- spec/scenario/config/initializers/secret_token.rb
|
197
|
-
- spec/scenario/config/initializers/session_store.rb
|
198
|
-
- spec/scenario/config/routes.rb
|
199
|
-
- spec/scenario/db/migrate/20100401102949_create_tables.rb
|
200
|
-
- spec/spec_helper.rb
|
201
|
-
- spec/strategy_spec.rb
|
202
|
-
- spec/support/migrations.rb
|
183
|
+
test_files: []
|
184
|
+
|