cassiopeia 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,9 @@
7
7
  - Yet another custom CAS client/server implementation. This plugin allows you to perform single-server authorization between two different rails applications.
8
8
 
9
9
  = Changelog:
10
+ - 0.2.0: Rails 3 support implemented (no backward compatibility with Rails 2)
11
+ - 0.1.7: First stage of compatibility with Rails 3 (RAILS_ROOT replaced with Rails.root)
12
+ - 0.1.6: Minor hot-fixes
10
13
  - 0.1.5: Method to_json of User class fixed.
11
14
  - 0.1.3: Removing request after return made optional
12
15
  - 0.1.2: Added some new parameters of request saving to the default configuration.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.summary = "Rails plugin for custom CAS(Cassiopeia) server/client implementation"
20
20
  s.add_dependency('uuidtools')
21
- s.add_dependency('rails', '>=2.3.5')
21
+ s.add_dependency('rails', '>=3.0.0')
22
22
  s.files = PKG_FILES.to_a
23
23
  s.require_path = "lib"
24
24
  s.has_rdoc = false
@@ -1,31 +1,28 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require "cassiopeia/railtie"
4
+
3
5
  module Cassiopeia
4
- VERSION = '0.1.7'
6
+ VERSION = '0.2.0'
5
7
  autoload :User, 'cassiopeia/user'
6
8
  autoload :Base, 'cassiopeia/base'
7
9
  autoload :Exception, 'cassiopeia/base'
8
10
  autoload :Server, 'cassiopeia/server'
9
11
  autoload :Client, 'cassiopeia/client'
10
- autoload :CONFIG, 'cassiopeia/config'
11
12
  autoload :ActiveRecordServerMixin, 'cassiopeia/active_record_server_mixin'
12
13
  autoload :ActionControllerServerMixin, 'cassiopeia/action_controller_server_mixin'
13
14
  autoload :ActionControllerClientMixin, 'cassiopeia/action_controller_client_mixin'
14
15
  autoload :RackRestoreRequest, 'cassiopeia/rack_restore_request'
15
16
  autoload :BaseRack, 'cassiopeia/base_rack'
16
17
  autoload :CassiopeiaRequest, 'cassiopeia/client'
18
+ autoload :CONFIG, 'cassiopeia/config'
17
19
 
18
20
  class << self
19
21
  def enable
20
22
  ActionController::Base.send :extend, ActionControllerServerMixin
21
23
  ActiveRecord::Base.send :extend, ActiveRecordServerMixin
22
24
  ActionController::Base.send :extend, ActionControllerClientMixin
23
- Rails.configuration.middleware.use RackRestoreRequest if CONFIG[:service_id]
24
25
  puts "Cassiopeia #{VERSION} enabled"
25
26
  end
26
27
  end
27
28
  end
28
-
29
- if defined? Rails && defined? Rails.root
30
- Cassiopeia.enable
31
- end
@@ -22,9 +22,10 @@ module Cassiopeia
22
22
  session[CAS_TICKET_ID_KEY] = nil
23
23
  end
24
24
  def cas_current_ticket_valid?
25
+ utc = ActiveSupport::TimeZone['UTC']
25
26
  logger.debug "\n Ticket.expires_at= #{cas_current_ticket[:expires_at]} \n" + "="*50 if cas_current_ticket
26
- logger.debug "\nCurrent ticket valid: #{DateTime.parse(cas_current_ticket[:expires_at])} >= #{DateTime.now}\n" + "="*50 if cas_current_ticket && cas_current_ticket[:expires_at]
27
- cas_current_ticket && DateTime.parse(cas_current_ticket[:expires_at]) >= DateTime.now if cas_current_ticket && cas_current_ticket[:expires_at]
27
+ logger.debug "\nCurrent ticket valid: #{utc.parse(cas_current_ticket[:expires_at])} >= #{Time.now.utc}\n" + "="*50 if cas_current_ticket && cas_current_ticket[:expires_at]
28
+ cas_current_ticket && utc.parse(cas_current_ticket[:expires_at]) >= Time.now.utc if cas_current_ticket && cas_current_ticket[:expires_at]
28
29
  end
29
30
  def cas_request_ticket_id
30
31
  logger.debug "\nStoring current request:...#{params[CAS_UNIQUE_REQ_KEY]} \n" + "="*50
@@ -2,7 +2,9 @@ module Cassiopeia
2
2
  class Base
3
3
  protected
4
4
  def query_to_hash(query)
5
- CGI.parse(query)
5
+ h = CGI.parse(query)
6
+ h.each { |k, v| h[k] = *v }
7
+ h
6
8
  end
7
9
 
8
10
  def hash_to_query(hash)
@@ -23,7 +23,7 @@ module Cassiopeia
23
23
 
24
24
  def cas_current_ticket_valid?(env)
25
25
  @ticket = cas_current_ticket(env)
26
- @ticket && DateTime.parse(@ticket[:expires_at]) >= DateTime.now if @ticket && @ticket[:expires_at]
26
+ @ticket && ActiveSupport::TimeZone['UTC'].parse(@ticket[:expires_at]) >= Time.now.utc if @ticket && @ticket[:expires_at]
27
27
  end
28
28
 
29
29
  def enabled
@@ -48,7 +48,7 @@ module Cassiopeia
48
48
  end
49
49
 
50
50
  def generate_expiration
51
- DateTime.now() + CAS_REQ_TIMEOUT / 24.0 / 60.0
51
+ Time.now.utc + CAS_REQ_TIMEOUT / 24.0 / 60.0
52
52
  end
53
53
 
54
54
  def generate_req_key
@@ -0,0 +1,10 @@
1
+ require "rails"
2
+
3
+ module Cassiopeia
4
+ class Railtie < Rails::Railtie
5
+ initializer 'cassiopeia.init_config' do
6
+ Cassiopeia.enable
7
+ Rails::Application.middleware.use Cassiopeia::RackRestoreRequest if Cassiopeia::CONFIG[:service_id]
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassiopeia
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 7
10
- version: 0.1.7
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - smecsia
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-08 00:00:00 +03:00
18
+ date: 2010-11-12 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,12 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- hash: 9
43
+ hash: 7
44
44
  segments:
45
- - 2
46
45
  - 3
47
- - 5
48
- version: 2.3.5
46
+ - 0
47
+ - 0
48
+ version: 3.0.0
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  description:
@@ -57,20 +57,21 @@ extensions: []
57
57
  extra_rdoc_files:
58
58
  - README.rdoc
59
59
  files:
60
- - README.rdoc
61
60
  - Rakefile
62
- - lib/cassiopeia.rb
61
+ - README.rdoc
62
+ - lib/cassiopeia/action_controller_client_mixin.rb
63
+ - lib/cassiopeia/rack_restore_request.rb
64
+ - lib/cassiopeia/user.rb
65
+ - lib/cassiopeia/server.rb
66
+ - lib/cassiopeia/client.rb
63
67
  - lib/cassiopeia/active_record_server_mixin.rb
64
- - lib/cassiopeia/base_rack.rb
65
68
  - lib/cassiopeia/action_controller_server_mixin.rb
69
+ - lib/cassiopeia/base_rack.rb
66
70
  - lib/cassiopeia/config.rb
67
- - lib/cassiopeia/server.rb
68
- - lib/cassiopeia/user.rb
69
- - lib/cassiopeia/rack_restore_request.rb
70
- - lib/cassiopeia/client.rb
71
71
  - lib/cassiopeia/tickets_controller_config.rb
72
- - lib/cassiopeia/action_controller_client_mixin.rb
73
72
  - lib/cassiopeia/base.rb
73
+ - lib/cassiopeia/railtie.rb
74
+ - lib/cassiopeia.rb
74
75
  has_rdoc: true
75
76
  homepage:
76
77
  licenses: []