cassiopeia 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +24 -21
- data/Rakefile +1 -1
- data/lib/cassiopeia/config.rb +2 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
- Yet another custom CAS client/server implementation
|
8
8
|
|
9
9
|
= Changelog:
|
10
|
+
- 0.0.4: Fixed problem with default config
|
10
11
|
- 0.0.3: Added required dependency simple_rest. Doc extended.
|
11
12
|
- 0.0.2: Added some doc
|
12
13
|
|
@@ -14,23 +15,25 @@
|
|
14
15
|
== SYNOPSIS:
|
15
16
|
=== Client configuration
|
16
17
|
<b>Create a file named config/cassiopeia.yml:</b>
|
17
|
-
|
18
18
|
server_url: "https://localhost/cassiopeia" # Url of cassiopeia server in your environment
|
19
19
|
service_url: "https://localhost/myservice" # Url of your application (for cas to redirect back)
|
20
20
|
service_id: "test" # Identification of your service (for informational and security purpose)
|
21
|
+
# additional options and their default values:
|
22
|
+
server_controller: "cas"
|
23
|
+
session_id_key: "cassiopeia_sesion_id"
|
24
|
+
ticket_id_key: "cas_ticket_id"
|
25
|
+
service_id_key: "cas_service_id"
|
26
|
+
service_url_key: "cas_service_url"
|
21
27
|
|
22
28
|
==== Usage:
|
23
29
|
<b>Add this line to application_controller.rb:</b>
|
24
|
-
|
25
30
|
use_cas_authorization
|
26
31
|
|
27
32
|
This will force your application to request authorization from cassiopeia server.
|
28
33
|
You can also check required roles to access some controllers. To do this, you should add the following line to your controller:
|
29
|
-
|
30
34
|
cas_require_roles :doctor, :admin
|
31
35
|
|
32
36
|
This will raise the Cassiopeia::AccessDeniedException if user try to access this controller. You can rescue from this exception by adding the following to application_controller.rb:
|
33
|
-
|
34
37
|
rescue_from 'Cassiopeia::AccessDeniedException', :with => :access_denied
|
35
38
|
def access_denied
|
36
39
|
flash[:notice] = 'Access denied. You dont have permissions to access this page'
|
@@ -38,14 +41,15 @@ This will raise the Cassiopeia::AccessDeniedException if user try to access this
|
|
38
41
|
end
|
39
42
|
|
40
43
|
=== Server configuration
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
Create a file named config/cassiopeia.yml:
|
44
45
|
ticket_max_lifetime: 5 # Ticket max lifetime (in minutes)
|
46
|
+
# additional options and their default values:
|
47
|
+
session_id_key: "cassiopeia_sesion_id"
|
48
|
+
ticket_id_key: "cas_ticket_id"
|
49
|
+
service_id_key: "cas_service_id"
|
50
|
+
service_url_key: "cas_service_url"
|
45
51
|
|
46
|
-
|
47
|
-
- Generate new controller named Cas. Generate new model named CasTicket. Create migration for your CasTicket (all field are mandatory):
|
48
|
-
|
52
|
+
Generate new controller named Cas. Generate new model named CasTicket. Create migration for your CasTicket (all field are mandatory):
|
49
53
|
def self.up
|
50
54
|
create_table :cas_tickets do |t|
|
51
55
|
t.references :user, :foreign_key => true
|
@@ -58,21 +62,15 @@ This will raise the Cassiopeia::AccessDeniedException if user try to access this
|
|
58
62
|
def self.down
|
59
63
|
drop_table :cas_tickets
|
60
64
|
end
|
61
|
-
|
62
|
-
- Add the following lines to your cas_controller:
|
63
|
-
|
65
|
+
Add the following lines to your cas_controller:
|
64
66
|
acts_as_cas_controller do |c|
|
65
67
|
c.ticketClass = CasTicket
|
66
68
|
c.rolesMethod = :roles_array #add this line only if your user model doesn't have :roles method
|
67
69
|
end
|
68
|
-
|
69
|
-
- Add the following lines to your CasTicket:
|
70
|
-
|
70
|
+
Add the following lines to your CasTicket:
|
71
71
|
acts_as_cas_ticket
|
72
72
|
belongs_to :user
|
73
|
-
|
74
|
-
- You should also provide the ability to extract user roles to array by calling rolesMethod for current user. Add this method to your user model. The example for authlogic:
|
75
|
-
|
73
|
+
You should also provide the ability to extract user roles to array by calling rolesMethod for current user. Add this method to your user model. The example for authlogic:
|
76
74
|
def roles_array
|
77
75
|
res = []
|
78
76
|
role_objects.each do |role|
|
@@ -80,14 +78,19 @@ This will raise the Cassiopeia::AccessDeniedException if user try to access this
|
|
80
78
|
end
|
81
79
|
res
|
82
80
|
end
|
81
|
+
One more thing that might be useful to make everything work properly. Add these lines to routes.rb:
|
82
|
+
map.resource :cas
|
83
|
+
map.root :controller => "cas", :action => :index
|
84
|
+
map.connect ':controller/:action.:format'
|
85
|
+
|
83
86
|
|
84
87
|
== INSTALL:
|
85
88
|
|
86
|
-
|
89
|
+
=== Add this line to environment.rb:
|
87
90
|
|
88
91
|
config.gem 'cassiopeia'
|
89
92
|
|
90
|
-
|
93
|
+
=== Run this from console:
|
91
94
|
|
92
95
|
rake gems:install
|
93
96
|
|
data/Rakefile
CHANGED
data/lib/cassiopeia/config.rb
CHANGED
@@ -12,7 +12,8 @@ module Cassiopeia
|
|
12
12
|
:server_url => "https://localhost/cassiopeia",
|
13
13
|
:service_url => "https://localhost/test_rails",
|
14
14
|
:service_id => "test",
|
15
|
-
:current_user_key => "current_user"
|
15
|
+
:current_user_key => "current_user",
|
16
|
+
:format => "js"
|
16
17
|
}
|
17
18
|
CONFIG_PATH = "#{RAILS_ROOT}/config/cassiopeia.yml"
|
18
19
|
@@conf = {}
|