devise_cas_authenticatable 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fd1ffe6c25dc2058cd0af67774f494903499870
4
- data.tar.gz: 860044267583de954f4c642d41cb938ad329b5c5
3
+ metadata.gz: afd477a0c8c3fbfdc6c1b7d93d716653511a2c0b
4
+ data.tar.gz: ab099c67e758e660a4ddf79237ccf7c172a18b00
5
5
  SHA512:
6
- metadata.gz: b99de7fc043aad27818675b314fb652815e1f926eb53782c7ca414b5ee6c289bc6fb796ff32c3be795a1335616bd591aa4abb0721cd09393c167b4fce5e5c0b7
7
- data.tar.gz: aebd6374f1595782c13f466b0fdea694913362bf84c08586134b1ff17dd1c4997654fac4f006526542b70115d9b040420db8670d7f478a909565f4b4e368c16d
6
+ metadata.gz: ded65e626018cddabb73244ef1c40c81534a5c5b564bc13d929e9041a0c186b061f9c4d89293da5c95d50e41a91c1de5be10c9dbebdd5694cf7dc3255a53e194
7
+ data.tar.gz: fcd19457ddfaa198c4832df3f6d85d75303835973e4fd1bbec899bf6af28e93160611d02390ce82a3302eb5ef50e9c80fbfe1923669f0c5289989bcf05402431
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog for devise\_cas\_authenticatable
2
2
 
3
+ ## Version 1.5.0 - July 27, 2015
4
+
5
+ * Generation of cas_action_url is now done by a customizable class, so you can use Rails routes to provide this (thanks to @eturino again!)
6
+
3
7
  ## Version 1.4.1 - July 23, 2015
4
8
 
5
9
  * Internal refactor to avoid conflicting with common route names, specifically logout_url (thanks to @eturino!)
data/README.md CHANGED
@@ -13,21 +13,14 @@ using [rubycas-server](http://github.com/gunark/rubycas-server)).
13
13
  Requirements
14
14
  ------------
15
15
 
16
- - Rails 2.3 or greater (works with 3.x and 4.x versions as well)
17
- - Devise 1.0 or greater
16
+ - Rails 3.0 or greater (works with 4.x versions as well)
17
+ - Devise 1.2 or greater
18
18
  - rubycas-client
19
19
 
20
20
  Installation
21
21
  ------------
22
22
 
23
- gem install --pre devise_cas_authenticatable
24
-
25
- and in your config/environment.rb (on Rails 2.3):
26
-
27
- config.gem 'devise', :version => '~> 1.0.6'
28
- config.gem 'devise_cas_authenticatable'
29
-
30
- or Gemfile (Rails 3.x):
23
+ Add to your Gemfile:
31
24
 
32
25
  gem 'devise'
33
26
  gem 'devise_cas_authenticatable'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{devise_cas_authenticatable}
5
- s.version = "1.4.1"
5
+ s.version = "1.5.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nat Budin", "Jeremy Haile"]
@@ -7,6 +7,8 @@ require 'devise_cas_authenticatable/exceptions'
7
7
 
8
8
  require 'devise_cas_authenticatable/single_sign_out'
9
9
 
10
+ require 'devise_cas_authenticatable/cas_action_url_factory_base'
11
+
10
12
  require 'rubycas-client'
11
13
 
12
14
  require 'devise_cas_authenticatable/railtie' if defined?(Rails::Railtie)
@@ -111,24 +113,11 @@ module Devise
111
113
 
112
114
  private
113
115
  def self.cas_action_url(base_url, mapping, action)
114
- u = URI.parse(base_url)
115
- u.query = nil
116
- u.path = if mapping.respond_to?(:fullpath)
117
- if ENV['RAILS_RELATIVE_URL_ROOT']
118
- ENV['RAILS_RELATIVE_URL_ROOT'] + mapping.fullpath
119
- else
120
- mapping.fullpath
121
- end
122
- else
123
- if ENV['RAILS_RELATIVE_URL_ROOT']
124
- ENV['RAILS_RELATIVE_URL_ROOT'] + mapping.raw_path
125
- else
126
- mapping.raw_path
127
- end
128
- end
129
- u.path << "/" unless u.path =~ /\/$/
130
- u.path << action
131
- u.to_s
116
+ cas_action_url_factory_class.new(base_url, mapping, action).call
117
+ end
118
+
119
+ def self.cas_action_url_factory_class
120
+ @cas_action_url_factory_class ||= CasActionUrlFactoryBase.prepare_class
132
121
  end
133
122
  end
134
123
 
@@ -0,0 +1,65 @@
1
+ module Devise
2
+ class CasActionUrlFactoryBase
3
+ attr_reader :base_url, :mapping, :action
4
+
5
+ def self.prepare_class
6
+ Class.new(self) do
7
+ include Rails.application.routes.url_helpers
8
+ include Rails.application.routes.mounted_helpers if Rails.application.routes.try(:mounted_helpers)
9
+ end
10
+ end
11
+
12
+ def initialize(base_url, mapping, action)
13
+ @base_url = base_url
14
+ @mapping = mapping
15
+ @action = action
16
+ end
17
+
18
+ def call
19
+ uri = URI.parse(base_url).tap { |uri| uri.query = nil }
20
+ uri.path = load_base_path
21
+ uri.to_s
22
+ end
23
+
24
+ alias_method :build, :call
25
+
26
+ private
27
+ def load_base_path
28
+ load_routes_path || load_mapping_path
29
+ end
30
+
31
+ def load_routes_path
32
+ router_name = mapping.router_name || Devise.available_router_name
33
+ context = send(router_name)
34
+
35
+ route = "#{mapping.singular}_#{action}_path"
36
+ if context.respond_to? route
37
+ context.send route
38
+ else
39
+ nil
40
+ end
41
+ rescue NameError, NoMethodError
42
+ nil
43
+ end
44
+
45
+ def load_mapping_path
46
+ path = mapping_fullpath || mapping_raw_path
47
+ path << "/" unless path =~ /\/$/
48
+ path << action
49
+ path
50
+ end
51
+
52
+ def mapping_fullpath
53
+ return nil unless mapping.respond_to?(:fullpath)
54
+ "#{rails_relative_url_root}#{mapping.fullpath}"
55
+ end
56
+
57
+ def mapping_raw_path
58
+ "#{rails_relative_url_root}#{mapping.raw_path}"
59
+ end
60
+
61
+ def rails_relative_url_root
62
+ ENV['RAILS_RELATIVE_URL_ROOT']
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_cas_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-23 00:00:00.000000000 Z
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -220,6 +220,7 @@ files:
220
220
  - app/views/devise/cas_sessions/unregistered.html.erb
221
221
  - devise_cas_authenticatable.gemspec
222
222
  - lib/devise_cas_authenticatable.rb
223
+ - lib/devise_cas_authenticatable/cas_action_url_factory_base.rb
223
224
  - lib/devise_cas_authenticatable/exceptions.rb
224
225
  - lib/devise_cas_authenticatable/model.rb
225
226
  - lib/devise_cas_authenticatable/railtie.rb