synapse-rubycas-server 1.1.3alpha

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.
Files changed (88) hide show
  1. checksums.yaml +15 -0
  2. data/CHANGELOG +353 -0
  3. data/Gemfile +12 -0
  4. data/LICENSE +26 -0
  5. data/README.md +38 -0
  6. data/Rakefile +3 -0
  7. data/bin/rubycas-server +30 -0
  8. data/config/config.example.yml +552 -0
  9. data/config/unicorn.rb +88 -0
  10. data/config.ru +11 -0
  11. data/db/migrate/001_create_initial_structure.rb +47 -0
  12. data/db/migrate/002_add_indexes_for_performance.rb +15 -0
  13. data/lib/casserver/authenticators/active_directory_ldap.rb +17 -0
  14. data/lib/casserver/authenticators/active_resource.rb +113 -0
  15. data/lib/casserver/authenticators/authlogic_crypto_providers/aes256.rb +43 -0
  16. data/lib/casserver/authenticators/authlogic_crypto_providers/bcrypt.rb +92 -0
  17. data/lib/casserver/authenticators/authlogic_crypto_providers/md5.rb +34 -0
  18. data/lib/casserver/authenticators/authlogic_crypto_providers/sha1.rb +59 -0
  19. data/lib/casserver/authenticators/authlogic_crypto_providers/sha512.rb +50 -0
  20. data/lib/casserver/authenticators/base.rb +70 -0
  21. data/lib/casserver/authenticators/client_certificate.rb +47 -0
  22. data/lib/casserver/authenticators/google.rb +62 -0
  23. data/lib/casserver/authenticators/ldap.rb +131 -0
  24. data/lib/casserver/authenticators/ntlm.rb +88 -0
  25. data/lib/casserver/authenticators/open_id.rb +19 -0
  26. data/lib/casserver/authenticators/sql.rb +158 -0
  27. data/lib/casserver/authenticators/sql_authlogic.rb +93 -0
  28. data/lib/casserver/authenticators/sql_bcrypt.rb +17 -0
  29. data/lib/casserver/authenticators/sql_encrypted.rb +75 -0
  30. data/lib/casserver/authenticators/sql_md5.rb +19 -0
  31. data/lib/casserver/authenticators/sql_rest_auth.rb +82 -0
  32. data/lib/casserver/authenticators/test.rb +21 -0
  33. data/lib/casserver/base.rb +13 -0
  34. data/lib/casserver/cas.rb +324 -0
  35. data/lib/casserver/core_ext/directory_user.rb +81 -0
  36. data/lib/casserver/core_ext/securerandom.rb +17 -0
  37. data/lib/casserver/core_ext/string.rb +22 -0
  38. data/lib/casserver/core_ext.rb +12 -0
  39. data/lib/casserver/model/consumable.rb +31 -0
  40. data/lib/casserver/model/ticket.rb +19 -0
  41. data/lib/casserver/model.rb +248 -0
  42. data/lib/casserver/server.rb +796 -0
  43. data/lib/casserver/utils.rb +20 -0
  44. data/lib/casserver/views/_login_form.erb +42 -0
  45. data/lib/casserver/views/layout.erb +18 -0
  46. data/lib/casserver/views/login.erb +30 -0
  47. data/lib/casserver/views/proxy.builder +13 -0
  48. data/lib/casserver/views/proxy_validate.builder +31 -0
  49. data/lib/casserver/views/service_validate.builder +24 -0
  50. data/lib/casserver/views/validate.erb +2 -0
  51. data/lib/casserver.rb +19 -0
  52. data/locales/de.yml +27 -0
  53. data/locales/en.yml +26 -0
  54. data/locales/es.yml +26 -0
  55. data/locales/es_ar.yml +26 -0
  56. data/locales/fr.yml +26 -0
  57. data/locales/it.yml +26 -0
  58. data/locales/jp.yml +26 -0
  59. data/locales/pl.yml +26 -0
  60. data/locales/pt.yml +26 -0
  61. data/locales/ru.yml +26 -0
  62. data/locales/zh.yml +26 -0
  63. data/locales/zh_tw.yml +26 -0
  64. data/public/themes/cas.css +126 -0
  65. data/public/themes/notice.png +0 -0
  66. data/public/themes/ok.png +0 -0
  67. data/public/themes/simple/bg.png +0 -0
  68. data/public/themes/simple/favicon.png +0 -0
  69. data/public/themes/simple/login_box_bg.png +0 -0
  70. data/public/themes/simple/logo.png +0 -0
  71. data/public/themes/simple/theme.css +28 -0
  72. data/public/themes/warning.png +0 -0
  73. data/resources/init.d.sh +58 -0
  74. data/spec/casserver/authenticators/active_resource_spec.rb +116 -0
  75. data/spec/casserver/authenticators/ldap_spec.rb +57 -0
  76. data/spec/casserver/cas_spec.rb +148 -0
  77. data/spec/casserver/model_spec.rb +42 -0
  78. data/spec/casserver/utils_spec.rb +24 -0
  79. data/spec/casserver_spec.rb +221 -0
  80. data/spec/config/alt_config.yml +50 -0
  81. data/spec/config/default_config.yml +56 -0
  82. data/spec/core_ext/string_spec.rb +28 -0
  83. data/spec/spec.opts +4 -0
  84. data/spec/spec_helper.rb +126 -0
  85. data/tasks/bundler.rake +4 -0
  86. data/tasks/db/migrate.rake +12 -0
  87. data/tasks/spec.rake +10 -0
  88. metadata +405 -0
@@ -0,0 +1,248 @@
1
+ require 'casserver/model/consumable'
2
+ require 'casserver/model/ticket'
3
+ require 'active_record'
4
+
5
+ module CASServer::Model
6
+
7
+ class LoginTicket < ActiveRecord::Base
8
+ include Consumable
9
+ include Ticket
10
+
11
+ if ActiveRecord::VERSION::STRING >= '3.2'
12
+ self.table_name = 'casserver_lt'
13
+ else
14
+ set_table_name 'casserver_lt'
15
+ end
16
+ end
17
+
18
+ class SPTicket < ActiveRecord::Base
19
+ include Consumable
20
+ include Ticket
21
+
22
+ if ActiveRecord::VERSION::STRING >= '3.2'
23
+ self.table_name = 'casserver_st'
24
+ else
25
+ set_table_name 'casserver_st'
26
+ end
27
+
28
+ def matches_service?(service)
29
+ CASServer::CAS.clean_service_url(self.service) ==
30
+ CASServer::CAS.clean_service_url(service)
31
+ end
32
+ end
33
+
34
+ class ServiceTicket < SPTicket
35
+ belongs_to :granted_by_tgt,
36
+ :class_name => 'CASServer::Model::TicketGrantingTicket',
37
+ :foreign_key => :granted_by_tgt_id
38
+ has_one :proxy_granting_ticket,
39
+ :foreign_key => :created_by_st_id
40
+ end
41
+
42
+ class ProxyTicket < SPTicket
43
+ belongs_to :granted_by_pgt,
44
+ :class_name => 'CASServer::Model::ProxyGrantingTicket',
45
+ :foreign_key => :granted_by_pgt_id
46
+ end
47
+
48
+ class TicketGrantingTicket < ActiveRecord::Base
49
+ include Ticket
50
+
51
+ if ActiveRecord::VERSION::STRING >= '3.2'
52
+ self.table_name = 'casserver_tgt'
53
+ else
54
+ set_table_name 'casserver_tgt'
55
+ end
56
+
57
+ serialize :extra_attributes
58
+
59
+ has_many :granted_service_tickets,
60
+ :class_name => 'CASServer::Model::ServiceTicket',
61
+ :foreign_key => :granted_by_tgt_id
62
+ end
63
+
64
+ class ProxyGrantingTicket < ActiveRecord::Base
65
+ include Ticket
66
+
67
+ if ActiveRecord::VERSION::STRING >= '3.2'
68
+ self.table_name = 'casserver_pgt'
69
+ else
70
+ set_table_name 'casserver_pgt'
71
+ end
72
+ belongs_to :service_ticket
73
+ has_many :granted_proxy_tickets,
74
+ :class_name => 'CASServer::Model::ProxyTicket',
75
+ :foreign_key => :granted_by_pgt_id
76
+ end
77
+
78
+ class Error
79
+ attr_reader :code, :message
80
+
81
+ def initialize(code, message)
82
+ @code = code
83
+ @message = message
84
+ end
85
+
86
+ def to_s
87
+ message
88
+ end
89
+ end
90
+
91
+ # class CreateCASServer < V 0.1
92
+ # def self.up
93
+ # if ActiveRecord::Base.connection.table_alias_length > 30
94
+ # $LOG.info("Creating database with long table names...")
95
+ #
96
+ # create_table :casserver_login_tickets, :force => true do |t|
97
+ # t.column :ticket, :string, :null => false
98
+ # t.column :created_on, :timestamp, :null => false
99
+ # t.column :consumed, :datetime, :null => true
100
+ # t.column :client_hostname, :string, :null => false
101
+ # end
102
+ #
103
+ # create_table :casserver_service_tickets, :force => true do |t|
104
+ # t.column :ticket, :string, :null => false
105
+ # t.column :service, :string, :null => false
106
+ # t.column :created_on, :timestamp, :null => false
107
+ # t.column :consumed, :datetime, :null => true
108
+ # t.column :client_hostname, :string, :null => false
109
+ # t.column :username, :string, :null => false
110
+ # t.column :type, :string, :null => false
111
+ # t.column :proxy_granting_ticket_id, :integer, :null => true
112
+ # end
113
+ #
114
+ # create_table :casserver_ticket_granting_tickets, :force => true do |t|
115
+ # t.column :ticket, :string, :null => false
116
+ # t.column :created_on, :timestamp, :null => false
117
+ # t.column :client_hostname, :string, :null => false
118
+ # t.column :username, :string, :null => false
119
+ # end
120
+ #
121
+ # create_table :casserver_proxy_granting_tickets, :force => true do |t|
122
+ # t.column :ticket, :string, :null => false
123
+ # t.column :created_on, :timestamp, :null => false
124
+ # t.column :client_hostname, :string, :null => false
125
+ # t.column :iou, :string, :null => false
126
+ # t.column :service_ticket_id, :integer, :null => false
127
+ # end
128
+ # end
129
+ # end
130
+ #
131
+ # def self.down
132
+ # if ActiveRecord::Base.connection.table_alias_length > 30
133
+ # drop_table :casserver_proxy_granting_tickets
134
+ # drop_table :casserver_ticket_granting_tickets
135
+ # drop_table :casserver_service_tickets
136
+ # drop_table :casserver_login_tickets
137
+ # end
138
+ # end
139
+ # end
140
+ #
141
+ # # Oracle table names cannot exceed 30 chars...
142
+ # # See http://code.google.com/p/rubycas-server/issues/detail?id=15
143
+ # class ShortenTableNames < V 0.5
144
+ # def self.up
145
+ # if ActiveRecord::Base.connection.table_alias_length > 30
146
+ # $LOG.info("Shortening table names")
147
+ # rename_table :casserver_login_tickets, :casserver_lt
148
+ # rename_table :casserver_service_tickets, :casserver_st
149
+ # rename_table :casserver_ticket_granting_tickets, :casserver_tgt
150
+ # rename_table :casserver_proxy_granting_tickets, :casserver_pgt
151
+ # else
152
+ # create_table :casserver_lt, :force => true do |t|
153
+ # t.column :ticket, :string, :null => false
154
+ # t.column :created_on, :timestamp, :null => false
155
+ # t.column :consumed, :datetime, :null => true
156
+ # t.column :client_hostname, :string, :null => false
157
+ # end
158
+ #
159
+ # create_table :casserver_st, :force => true do |t|
160
+ # t.column :ticket, :string, :null => false
161
+ # t.column :service, :string, :null => false
162
+ # t.column :created_on, :timestamp, :null => false
163
+ # t.column :consumed, :datetime, :null => true
164
+ # t.column :client_hostname, :string, :null => false
165
+ # t.column :username, :string, :null => false
166
+ # t.column :type, :string, :null => false
167
+ # t.column :proxy_granting_ticket_id, :integer, :null => true
168
+ # end
169
+ #
170
+ # create_table :casserver_tgt, :force => true do |t|
171
+ # t.column :ticket, :string, :null => false
172
+ # t.column :created_on, :timestamp, :null => false
173
+ # t.column :client_hostname, :string, :null => false
174
+ # t.column :username, :string, :null => false
175
+ # end
176
+ #
177
+ # create_table :casserver_pgt, :force => true do |t|
178
+ # t.column :ticket, :string, :null => false
179
+ # t.column :created_on, :timestamp, :null => false
180
+ # t.column :client_hostname, :string, :null => false
181
+ # t.column :iou, :string, :null => false
182
+ # t.column :service_ticket_id, :integer, :null => false
183
+ # end
184
+ # end
185
+ # end
186
+ #
187
+ # def self.down
188
+ # if ActiveRecord::Base.connection.table_alias_length > 30
189
+ # rename_table :casserver_lt, :cassserver_login_tickets
190
+ # rename_table :casserver_st, :casserver_service_tickets
191
+ # rename_table :casserver_tgt, :casserver_ticket_granting_tickets
192
+ # rename_table :casserver_pgt, :casserver_proxy_granting_tickets
193
+ # else
194
+ # drop_table :casserver_pgt
195
+ # drop_table :casserver_tgt
196
+ # drop_table :casserver_st
197
+ # drop_table :casserver_lt
198
+ # end
199
+ # end
200
+ # end
201
+ #
202
+ # class AddTgtToSt < V 0.7
203
+ # def self.up
204
+ # add_column :casserver_st, :tgt_id, :integer, :null => true
205
+ # end
206
+ #
207
+ # def self.down
208
+ # remove_column :casserver_st, :tgt_id, :integer
209
+ # end
210
+ # end
211
+ #
212
+ # class ChangeServiceToText < V 0.71
213
+ # def self.up
214
+ # # using change_column to change the column type from :string to :text
215
+ # # doesn't seem to work, at least under MySQL, so we drop and re-create
216
+ # # the column instead
217
+ # remove_column :casserver_st, :service
218
+ # say "WARNING: All existing service tickets are being deleted."
219
+ # add_column :casserver_st, :service, :text
220
+ # end
221
+ #
222
+ # def self.down
223
+ # change_column :casserver_st, :service, :string
224
+ # end
225
+ # end
226
+ #
227
+ # class AddExtraAttributes < V 0.72
228
+ # def self.up
229
+ # add_column :casserver_tgt, :extra_attributes, :text
230
+ # end
231
+ #
232
+ # def self.down
233
+ # remove_column :casserver_tgt, :extra_attributes
234
+ # end
235
+ # end
236
+ #
237
+ # class RenamePgtForeignKeys < V 0.80
238
+ # def self.up
239
+ # rename_column :casserver_st, :proxy_granting_ticket_id, :granted_by_pgt_id
240
+ # rename_column :casserver_st, :tgt_id, :granted_by_tgt_id
241
+ # end
242
+ #
243
+ # def self.down
244
+ # rename_column :casserver_st, :granted_by_pgt_id, :proxy_granting_ticket_id
245
+ # rename_column :casserver_st, :granted_by_tgt_id, :tgt_id
246
+ # end
247
+ # end
248
+ end