cassiopeia 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,6 +7,7 @@
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.0.7: Some code for redirection added. Added webpath prefix support.
10
11
  - 0.0.6: Tiny refactoring.
11
12
  - 0.0.5: Some important fixes for configuration exceptions handling.
12
13
  - 0.0.4: Fixed problem with default config.
@@ -29,15 +30,10 @@
29
30
  == SYNOPSIS:
30
31
  === Client configuration
31
32
  <b>Create a file named config/cassiopeia.yml:</b>
32
- server_url: "https://localhost/cassiopeia" # Url of cassiopeia server in your environment
33
- service_url: "https://localhost/myservice" # Url of your application (for cas to redirect back)
34
- service_id: "test" # Identification of your service (for informational and security purpose)
35
- # additional options and their default values:
36
- server_controller: "cas"
37
- session_id_key: "cassiopeia_sesion_id"
38
- ticket_id_key: "cas_ticket_id"
39
- service_id_key: "cas_service_id"
40
- service_url_key: "cas_service_url"
33
+ server_url: "https://localhost" # Url of cassiopeia server in your environment
34
+ service_url: "https://localhost/myservice/" # Url of your application (for cas to redirect back)
35
+ service_id: "myservice" # Identification of your service (for informational and security purpose)
36
+ webpath_prefix: "/myservice" # This is used just for correct redirection if you use proxy (default: empty)
41
37
 
42
38
  ==== Usage:
43
39
  <b>Add this line to application_controller.rb:</b>
@@ -56,12 +52,7 @@ This will raise the Cassiopeia::Exception::AccessDenied if user try to access th
56
52
 
57
53
  === Server configuration
58
54
  Create a file named config/cassiopeia.yml:
59
- ticket_max_lifetime: 5 # Ticket max lifetime (in minutes)
60
- # additional options and their default values:
61
- session_id_key: "cassiopeia_sesion_id"
62
- ticket_id_key: "cas_ticket_id"
63
- service_id_key: "cas_service_id"
64
- service_url_key: "cas_service_url"
55
+ ticket_max_lifetime: 5 # Ticket max lifetime (in minutes, default: 120)
65
56
 
66
57
  Generate new controller named Cas. Generate new model named CasTicket. Create migration for your CasTicket (all field are mandatory):
67
58
  def self.up
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ PKG_FILES = FileList[ '[a-zA-Z]*', 'lib/**/*' ]
10
10
 
11
11
  spec = Gem::Specification.new do |s|
12
12
  s.name = "cassiopeia"
13
- s.version = "0.0.6"
13
+ s.version = "0.0.7"
14
14
  s.author = "smecsia"
15
15
  s.email = "smecsia@gmail.com"
16
16
  #s.homepage = ""
@@ -5,6 +5,8 @@ module Cassiopeia
5
5
  ::CAS_USER_KEY = Cassiopeia::CONFIG[:current_user_key]
6
6
  ::CAS_TICKET_ID_KEY = Cassiopeia::CONFIG[:ticket_id_key]
7
7
  ::CAS_TICKET_KEY = Cassiopeia::CONFIG[:ticket_key]
8
+ ::CAS_WEBPATH_PREFIX = Cassiopeia::CONFIG[:webpath_prefix]
9
+ ::CAS_RETURN_TO_KEY = Cassiopeia::CONFIG[:return_to_key]
8
10
  def cas_current_ticket
9
11
  session[CAS_TICKET_KEY] || params[CAS_TICKET_KEY]
10
12
  end
@@ -24,8 +26,15 @@ module Cassiopeia
24
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]
25
27
  cas_current_ticket && DateTime.parse(cas_current_ticket[:expires_at]) >= DateTime.now if cas_current_ticket && cas_current_ticket[:expires_at]
26
28
  end
29
+ def cas_store_location
30
+ session[CAS_RETURN_TO_KEY] = "#{CAS_WEBPATH_PREFIX}#{request.request_uri}"
31
+ end
32
+ def cas_redirect_back_or_default(default)
33
+ redirect_to(session[CAS_RETURN_TO_KEY] || default)
34
+ session[CAS_RETURN_TO_KEY] = nil
35
+ end
27
36
  def cas_request_ticket_id
28
- store_location if respond_to?('store_location')
37
+ cas_store_location
29
38
  redirect_to Cassiopeia::Client::instance.cas_check_url(session)
30
39
  end
31
40
  def cas_request_current_user
@@ -35,7 +44,7 @@ module Cassiopeia
35
44
  logger.debug "\nCurrent user identified (#{@current_user.login}), storing to session\n" + "="*50
36
45
  cas_store_current_user(@ticket, @current_user)
37
46
  logger.debug "\nShould redirect user to #{session[:return_to]}\n" + "="*50
38
- redirect_back_or_default root_path if respond_to?('redirect_back_or_default')
47
+ cas_redirect_back_or_default root_path
39
48
  end
40
49
  def cas_required_roles
41
50
  self.class.cas_required_roles if self.class.respond_to? :cas_required_roles
@@ -10,8 +10,10 @@ module Cassiopeia
10
10
  :service_id_key => "cas_service_id",
11
11
  :service_url_key => "cas_service_url",
12
12
  :server_url => "https://localhost/cassiopeia",
13
- :service_url => "https://localhost/test_rails",
14
- :service_id => "test",
13
+ :service_url => "https://localhost/",
14
+ :webpath_prefix => "",
15
+ :return_to_key => "cas_return_to",
16
+ :service_id => "casclient",
15
17
  :current_user_key => "current_user",
16
18
  :format => "js"
17
19
  }
data/lib/cassiopeia.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
  module Cassiopeia
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.7'
5
5
  autoload :User, 'cassiopeia/user'
6
6
  autoload :Base, 'cassiopeia/base'
7
7
  autoload :Exception, 'cassiopeia/base'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassiopeia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - smecsia
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-17 00:00:00 +03:00
12
+ date: 2010-04-07 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency