uchouhan-rubycas-server 1.0.a

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 (83) hide show
  1. data/CHANGELOG +289 -0
  2. data/LICENSE +26 -0
  3. data/README.md +19 -0
  4. data/Rakefile +1 -0
  5. data/bin/rubycas-server +16 -0
  6. data/bin/rubycas-server-ctl +9 -0
  7. data/lib/casserver.rb +13 -0
  8. data/lib/casserver/authenticators/active_directory_ldap.rb +19 -0
  9. data/lib/casserver/authenticators/authlogic_crypto_providers/aes256.rb +43 -0
  10. data/lib/casserver/authenticators/authlogic_crypto_providers/bcrypt.rb +92 -0
  11. data/lib/casserver/authenticators/authlogic_crypto_providers/md5.rb +34 -0
  12. data/lib/casserver/authenticators/authlogic_crypto_providers/sha1.rb +59 -0
  13. data/lib/casserver/authenticators/authlogic_crypto_providers/sha512.rb +50 -0
  14. data/lib/casserver/authenticators/base.rb +67 -0
  15. data/lib/casserver/authenticators/client_certificate.rb +47 -0
  16. data/lib/casserver/authenticators/google.rb +58 -0
  17. data/lib/casserver/authenticators/ldap.rb +147 -0
  18. data/lib/casserver/authenticators/ntlm.rb +88 -0
  19. data/lib/casserver/authenticators/open_id.rb +22 -0
  20. data/lib/casserver/authenticators/sql.rb +133 -0
  21. data/lib/casserver/authenticators/sql_authlogic.rb +93 -0
  22. data/lib/casserver/authenticators/sql_encrypted.rb +77 -0
  23. data/lib/casserver/authenticators/sql_md5.rb +19 -0
  24. data/lib/casserver/authenticators/sql_rest_auth.rb +85 -0
  25. data/lib/casserver/authenticators/tacc.rb +67 -0
  26. data/lib/casserver/authenticators/test.rb +21 -0
  27. data/lib/casserver/cas.rb +327 -0
  28. data/lib/casserver/localization.rb +91 -0
  29. data/lib/casserver/model.rb +269 -0
  30. data/lib/casserver/server.rb +623 -0
  31. data/lib/casserver/utils.rb +32 -0
  32. data/lib/casserver/views/_login_form.erb +41 -0
  33. data/lib/casserver/views/layout.erb +17 -0
  34. data/lib/casserver/views/login.erb +29 -0
  35. data/lib/casserver/views/proxy.builder +11 -0
  36. data/lib/casserver/views/proxy_validate.builder +26 -0
  37. data/lib/casserver/views/service_validate.builder +19 -0
  38. data/lib/casserver/views/validate.erb +1 -0
  39. data/po/de_DE/rubycas-server.po +127 -0
  40. data/po/es_ES/rubycas-server.po +123 -0
  41. data/po/fr_FR/rubycas-server.po +128 -0
  42. data/po/ja_JP/rubycas-server.po +126 -0
  43. data/po/pl_PL/rubycas-server.po +123 -0
  44. data/po/pt_BR/rubycas-server.po +123 -0
  45. data/po/ru_RU/rubycas-server.po +118 -0
  46. data/po/rubycas-server.pot +112 -0
  47. data/po/zh_CN/rubycas-server.po +113 -0
  48. data/po/zh_TW/rubycas-server.po +113 -0
  49. data/public/themes/cas.css +121 -0
  50. data/public/themes/notice.png +0 -0
  51. data/public/themes/ok.png +0 -0
  52. data/public/themes/simple/bg.png +0 -0
  53. data/public/themes/simple/favicon.png +0 -0
  54. data/public/themes/simple/login_box_bg.png +0 -0
  55. data/public/themes/simple/logo.png +0 -0
  56. data/public/themes/simple/theme.css +28 -0
  57. data/public/themes/tadnet/bg.png +0 -0
  58. data/public/themes/tadnet/button.png +0 -0
  59. data/public/themes/tadnet/favicon.png +0 -0
  60. data/public/themes/tadnet/login_box_bg.png +0 -0
  61. data/public/themes/tadnet/logo.png +0 -0
  62. data/public/themes/tadnet/theme.css +55 -0
  63. data/public/themes/urbacon/bg.png +0 -0
  64. data/public/themes/urbacon/login_box_bg.png +0 -0
  65. data/public/themes/urbacon/logo.png +0 -0
  66. data/public/themes/urbacon/theme.css +33 -0
  67. data/public/themes/warning.png +0 -0
  68. data/resources/config.example.yml +574 -0
  69. data/resources/config.ru +42 -0
  70. data/resources/custom_views.example.rb +11 -0
  71. data/resources/init.d.sh +58 -0
  72. data/rubycas-server.gemspec +40 -0
  73. data/setup.rb +1585 -0
  74. data/spec/alt_config.yml +46 -0
  75. data/spec/casserver_spec.rb +114 -0
  76. data/spec/default_config.yml +46 -0
  77. data/spec/spec.opts +4 -0
  78. data/spec/spec_helper.rb +89 -0
  79. data/tasks/bundler.rake +4 -0
  80. data/tasks/db/migrate.rake +12 -0
  81. data/tasks/localization.rake +13 -0
  82. data/tasks/spec.rake +10 -0
  83. metadata +172 -0
data/CHANGELOG ADDED
@@ -0,0 +1,289 @@
1
+ === 1.0.0 :: In Progress...
2
+
3
+ * NEW:
4
+ * Rewrite to replace Camping/Picnic with Sinatra
5
+ * Support for Ruby 1.9.2
6
+ * Support for Active Record 3
7
+
8
+ === 0.8.0
9
+
10
+ * NEW:
11
+ * Support for localization via Ruby-GetText.
12
+ See http://code.google.com/p/rubycas-server/wiki/Localization
13
+ for details. [antono]
14
+ * Switched to Picnic 0.8.x, so RubyCAS-Server is now based on Rack
15
+ and Camping 2.0 and is now compatible with Passenger Phusion
16
+ * Change to authenticator API: every authenticator now has a class 'setup'
17
+ method that gets called at server startup. This is where class-level
18
+ configuration should be done (e.g. establishing a database connection).
19
+ This is different from the 'configure' method which gets called on a per-
20
+ instance basis for each authenticator. [godfat]
21
+ * Database connections are now automatically released back to the connection
22
+ pool at the end of each request. This should allow the server to handle
23
+ many more concurrent requests, since database connections are no longer left
24
+ checked out of the pool.
25
+ * Added new SQL authenticator (sql_rest_auth) compatible with the
26
+ restful_authentication Rails plugin. [antono]
27
+ * Re-licensed under the MIT License.
28
+
29
+ * FIXED:
30
+ * Fixed weird problems with loading controllers when using older versions of
31
+ activesupport and/or rubygems.
32
+ * Failure to connect to a service during a single sign out request is now
33
+ handled gracefully.
34
+ * Required gem dependencies have been re-enabled in the gemspec.
35
+ * Authlogic authenticator files added to gemspec. [rajiv]
36
+ * Authenticators are now instantiated on a per-request basis (rather than
37
+ once at startup) to ensure thread safety.
38
+
39
+ === 0.7.1 :: 2008-11-10
40
+
41
+ * Fixed dependency loading problems introduced by upstream changes in RubyGems
42
+ 1.3.1.
43
+
44
+ === 0.7.0 :: 2008-11-04
45
+
46
+ * NEW:
47
+ * Implemented single-sign-out functionality as specified in CAS 3.3. See
48
+ http://www.ja-sig.org/wiki/display/CASUM/Single+Sign+Out.
49
+ * It is now possible to configure Authenticators to return extra attributes
50
+ to CAS clients alongside the username. For an example of how to do this see
51
+ the included SQL authenticator. Also have a look at:
52
+ http://groups.google.com/group/rubycas-server/browse_thread/thread/5eade3793cb590e9
53
+ Note that extra attributes of type other than String or Numeric are serialized
54
+ into YAML format before being sent along to the client.
55
+ * Added an MD5-password version of the SQL authenticator for Drupal and any other
56
+ database that stores its passwords in hashed form (thanks malcolmm).
57
+ * Added new Google authenticator for authenticating against Google/GMail
58
+ accounts.
59
+
60
+ * CHANGED:
61
+ * Service URIs are now automatically normalized. For example, if the service
62
+ URI given to the server has a 'ticket' parameter, the ticket will now be
63
+ automatically stripped. This is to avert any possible issues raised by
64
+ misbehaving CAS clients (the CAS ticket should never be part of the service
65
+ URI). Same goes for other CAS-related parameters like 'service', 'renew',
66
+ and 'gateway'. Additionally, the trailing '/' and '?' characters are
67
+ automatically stripped from URLs, since, for example, "http://google.com/"
68
+ is almost certainly equivalent to "http://google.com".
69
+ * The expire_sessions config variable is now respected -- ticket granting
70
+ ticket cookies are set with an expiry datetime, so that the SSO session
71
+ is effectively terminated once the ticket_granting_ticket_expiry period
72
+ is reached.
73
+ * If present, the HTTP_X_FORWARDED_FOR header is used for recording the
74
+ client's address. This is useful when the server is running behind a reverse
75
+ proxy, but it should not be considered authoritative since it can be
76
+ easily spoofed.
77
+ * The 'service' field in the 'casserver_st' table has been changed from
78
+ VARCHAR(255) to TEXT in order to accomodate service URIs longer than 255
79
+ characters (fixes issue #46).
80
+ * The CAS XML responses are no longer whitespace-formatted (i.e. Markaby's
81
+ auto-indentation has been turned off). Apparently the whitespace was
82
+ causing problems with mod_auth_cas. See:
83
+ http://groups.google.com/group/rubycas-server/browse_thread/thread/e482fe09999b73d3
84
+ * When used without pre-authentication, the LDAP authenticator now tries to
85
+ bind by searching for the given username in the LDAP directory based on the
86
+ configured username_attribute. Prior to this change the authenticator
87
+ attempted to bind with the LDAP server by assuming that the username credential
88
+ matches the user's CN. This is no longer the case.
89
+ * CAS responses to invalid requests (for example where required parameters
90
+ are missing or incorrect) will now have HTTP status code 422. Internal server
91
+ errors (where the server rather than the client is at fault) have error 500.
92
+ Previously most responses had error code 200, regardless of their contents.
93
+
94
+ * FIXED:
95
+ * Fixed logout action to work properly with ActiveRecord 2.1 (eager loading behaviour
96
+ was changed upstream forcing a change to the way we look for ProxyGrantingTickets
97
+ to delete on logout).
98
+ * When running under Mongrel, the USR2 signal should now restart the server as
99
+ expected -- however currently this only works when the server is running
100
+ in the foregaround. When daemonized, USR2 will shut down the server without
101
+ restarting (see issue #58).
102
+ * Fixed activerecord/activesupport gem load problems, hopefully once and for all
103
+ (however picnic-0.7.0 is now required).
104
+
105
+ === 0.6.0 :: 2008-03-28
106
+
107
+ * Much of the supporting functionality that makes RubyCAS-Server
108
+ act as a well-behaved Linux service has been abstracted out
109
+ into its own library. This new library is called Picnic and is
110
+ now a gem dependency for RubyCAS-Server. You can find out more about
111
+ it at http://code.google.com/p/camping-picnic/.
112
+ * The logout action will now accept a 'destination' parameter in lieu of
113
+ 'service'. This means that if a 'destination' parameter is given with
114
+ some URL, the logout action will show the login form, allowing the user
115
+ to immedietly log back in to the service specified by 'destination'.
116
+ * The logout action will now accept a 'url' parameter. If given, the logout
117
+ page will show a message indicating that the CAS session has been terminated
118
+ and instructing the user to click on a link to follow the given URL. If the
119
+ 'url' parameter is given, the login form will NOT be shown on the logout
120
+ page (see above).
121
+ * When an authentication failure occurs (because the user submitted
122
+ invalid credentials or the login ticket is missing), the server
123
+ now returns a 401 (Unauthorized) response instead of 200.
124
+ * An encryption-enabled version of the SQL authenticator is now
125
+ available. For more info have a look at:
126
+ http://code.google.com/p/rubycas-server/wiki/UsingTheSQLEncryptedAuthenticator
127
+ * Better compatibility with Oracle databases. The database migration
128
+ no longer tries to create tables with long names when long
129
+ table names are not supported by the underlying database connector
130
+ (issue #15).
131
+ * The server now automatically removes leading and trailing whitespace from
132
+ the username entered by users. Passwords however are left intact, with no
133
+ whitespace removed.
134
+ * The server can now be configured to automatically downcase the
135
+ username entered by users (dowcase_username option). So if a user
136
+ enters "JSmith", the system will convert it to "jsmith" if the
137
+ downcase_username option is set to true.
138
+ * The server can now be made to bind to a specific address. See the
139
+ :bind_address option in the config.example.yml file.
140
+ * Fixed bug with ActiveRecord 2.0.2 where service tickets were not
141
+ being given a type (issue #37).
142
+
143
+ === 0.5.1 :: 2007-12-20
144
+
145
+ * Tickets generated by the server should now be a lot more secure.
146
+ The random string generator used for generating tickets now uses
147
+ Crypt::ISAAC. Tickets have also been extended in length; STs, PTs
148
+ and LTs can now extend up to 32 characters, and PGTs and PGT-IOUs
149
+ up to 64.
150
+
151
+ === 0.5.0 :: 2007-09-20
152
+
153
+ * Gateway requests should now be handled correctly. When the request to the
154
+ login page is made with gateway=true as one of the parameters, the CAS
155
+ server will immediately redirect back to the target service along with
156
+ a service ticket if an SSO session exists for the user (or without a
157
+ service ticket if there is no pre-existing SSO session).
158
+ Note that if you are using RubyCAS-Client and want gatewaying, you will
159
+ need to upgrade it to 1.1.0 as gatewaying was broken in prior versions.
160
+ * If gateway=true is specified as part of the logout URI, the server will
161
+ log the user out and immediately redirect them back to the specified
162
+ service. In other words, you can now do "gatewayed logouts" as well
163
+ as logins.
164
+ * A login ticket can now be remotely requested from the server by placing
165
+ a POST request to '/loginTicket'.
166
+ * The login view can now be made to return only the login form. This is
167
+ done by adding the 'onlyLoginForm' parameter to the '/login' request.
168
+ Optionally, a 'submitToURI' parameter can be supplied to force the login
169
+ form to submit to the given URI (otherwise the server will try to figure
170
+ out the full URI to its own login controller). This functionality may be
171
+ useful when you want to embed the login form in some external page, as
172
+ an IFRAME otherwise.
173
+ * Custom views can now be used to override the default Markaby templates
174
+ by specifying a 'custom_views_file' option in the configuration. See
175
+ custom_views.example.rb. [jzylks]
176
+ * Table names have been shortened to work with Oracle. A migration has
177
+ been added that should do the shortening for you the first time you run
178
+ this new RubyCAS-Server version.
179
+ * Multiple authenticators can now be specified. During authentication,
180
+ credentials are presented to the first authenticator, then the second,
181
+ and so on, until the user is validated by any one authenticator or fails
182
+ validation for all of them. [jzylks]
183
+ * When using webrick, you can now run with SSL disabled by omitting the
184
+ ssl_cert and ssl_key parameters.
185
+ * Changed incorrect MySQL example database configuration -- option should
186
+ be 'host:' not 'server:' (issue #22).
187
+
188
+ === 0.4.2 :: 2007-07-26
189
+
190
+ * The LDAP/AD authenticator has been largely re-written. The code is a bit
191
+ cleaner now, and should work better with non-Active Directory LDAP servers
192
+ (although this has yet to be tested since I don't have access to a non-AD
193
+ LDAP server).
194
+ * The validate() method in your authenticators now receives a :service element
195
+ (in addition to :username, and :password). This is simply the service
196
+ url (if any) specified in the user's CAS request. If you call
197
+ read_standard_credentials(credentials) at the top of your validator, the value
198
+ will also be available as @service along with @username and @password.
199
+ * By request, a :username_prefix option has been added to the ldap
200
+ configuration. If entered, this string will be automatically prefixed to
201
+ the username entered by the user.
202
+ * A bug having to do with handling authenticator errors has been fixed.
203
+ Any authenticator error messages should now be correctly shown on the
204
+ login page.
205
+ * Minor improvements to error messages having to do with login tickets.
206
+ They're a bit more prescriptive now, explaining to the user what steps
207
+ they should take to correct the error.
208
+
209
+ === 0.4.1 :: 2007-06-07
210
+
211
+ * This release restores compatiblity with older versions of rubygems
212
+ (pre-0.9.0). To achieve this, we alias the 'gem' method to the old
213
+ 'require_gem' if 'gem' is not already defined.
214
+ * rubycas-server-ctl will now quiety delete an orphaned .pid file
215
+ instead complaining loudly and refusing to start up.
216
+ * Fixed minor bug in rubycas-server-ctl that sometimes incorrectly reported
217
+ startup problems when in fact the server had started just fine.
218
+
219
+
220
+ === 0.4.0 :: 2007-06-05
221
+
222
+ * Added rubycas-server-ctl script for controlling daemonized server.
223
+ * rubygems-0.9.0 or later is now required.
224
+ * Added system startup script to be used in /etc/init.d on Linux systems.
225
+ * Authenticator can now be loaded from an external file using the 'source'
226
+ configuration option.
227
+ * Better preemptive detection of startup problems with mongrel.
228
+ * User now sees an error message if the service URI is not a valid URI (i.e.
229
+ if it's not URI-encoded or otherwise malformed).
230
+
231
+
232
+ === 0.3.0 :: 2007-03-29
233
+
234
+ * Fixed glaring security problem with LDAP/AD Authenticator where under some
235
+ circumstances blank passwords were accepted as valid.
236
+ * Autocomplete has been turned off on the password field for better security.
237
+ In the future we may allow autocomplete to be re-enabled using a
238
+ configuration setting.
239
+ * When the user visits the login page and is already authenticated (i.e. they
240
+ have a valid ticket granting cookie), a message is shown at the top
241
+ indicating that they are already logged in.
242
+ * sqlite3-ruby is no longer required by the gem as a dependency. The user
243
+ must now install it manually prior to installing rubycas-server. The
244
+ building of sqlite3 native extensions appears to be somewhat flakey
245
+ and probably defeats the original purpose of using it (which was
246
+ to have a CAS server up and running with no additional DB configuration).
247
+ We will use MySQL as the default database adapter instead, since it does
248
+ not require additional libraries and many users will have a MySQL server
249
+ already available.
250
+ * Fixed bug that was causing all proxy-granting tickets to be deleted whenever
251
+ any user logged out. Only the PGTs for the user that is logging out are now
252
+ being deleted.
253
+ * Trailing slashes in service URLs are now ignored when validating service
254
+ and proxy tickets (e.g. "http://www.google.com" and "http://www.google.com/"
255
+ are now considered to be the same service URL).
256
+ * Authenticators now raise AuthenticatorError exceptions when encountering
257
+ a problem/error. This makes it easier to send feedback to the user.
258
+ However, other exceptions should still be raised when errors ought
259
+ not be recoverable (i.e. programming errors).
260
+ * Fixed serious vulnerability in LDAP authenticator where under some
261
+ cirumstances the user could just enter '*' as their username to match
262
+ any username. The LDAP authenticator will now refuse to process logins
263
+ with usernames that contain the characters * ( ) \ / and the NULL
264
+ character \0.
265
+ * Views are no longer xhtml-validated. Markaby's auto-validation was turned
266
+ off to allow for use of the autocomplete property on inputs, since this is
267
+ the only viable way of turning off password storage in IE and Firefox at
268
+ the page level.
269
+ * You can now limit the maximum length of a login session by setting the
270
+ expire_sessions config setting to true.
271
+ * Fixed some minor bugs in the login view.
272
+
273
+
274
+ === 0.2.0 :: 2007-03-20
275
+
276
+ * ruby-casserver now behaves more like a real command-line app, accepting
277
+ various command line arguments including -h (help), -v (version), -c (use
278
+ an alternate config.yml), and -d (daemonize, when using webrick or mongrel
279
+ mode).
280
+ * Special characters in CAS XML responses are now properly encoded into XML
281
+ entities
282
+ * CAS XML responses are no longer auto-indented... Markaby's indentation
283
+ seemed to be causing problems with the PHP CAS client.
284
+ * Misc minor bug fixes/cleanup.
285
+
286
+
287
+ === 0.1.0 :: 2007-03-01
288
+
289
+ * First public release.
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Portions of RubyCAS-Server contributed by Matt Zukowski are copyright (c) 2009 Urbacon Ltd.
2
+ Other portions are copyright of their respective authors.
3
+
4
+ The MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the "Software"), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
26
+
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # RubyCAS-Server
2
+
3
+ ## Copyright
4
+
5
+ Portions contributed by Matt Zukowski are copyright (c) 2010 Urbacon Ltd.
6
+ Other portions are copyright of their respective authors.
7
+
8
+ ## Authors
9
+
10
+ See http://github.com/gunark/rubycas-server/commits/
11
+
12
+ ## Installation
13
+
14
+ For info and detailed installation instructions please see http://code.google.com/p/rubycas-server
15
+
16
+ ## License
17
+
18
+ RubyCAS-Server is licensed for use under the terms of the MIT License.
19
+ See the LICENSE file bundled with the official RubyCAS-Server distribution for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Enables UTF-8 compatibility.
4
+ $KCODE = 'u' if RUBY_VERSION < '1.9'
5
+
6
+ require 'rubygems'
7
+
8
+ $: << File.dirname(__FILE__) + "/../lib"
9
+
10
+ if ARGV.join.match('--debugger')
11
+ require 'ruby-debug'
12
+ puts "=> Debugger Enabled"
13
+ end
14
+ require 'casserver'
15
+
16
+ CASServer::Server.run!
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.dirname(__FILE__)+"/../lib/casserver/load_picnic")
4
+
5
+ require 'picnic/service_control'
6
+
7
+ ctl = Picnic::ServiceControl.new('rubycas-server')
8
+
9
+ ctl.handle_cli_input
data/lib/casserver.rb ADDED
@@ -0,0 +1,13 @@
1
+ module CASServer; end
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__) + '/casserver')
4
+ $: << File.expand_path(File.dirname(__FILE__) + '/../vendor/isaac_0.9.1')
5
+
6
+ require 'active_record'
7
+ require 'active_support'
8
+ require 'sinatra/base'
9
+ require 'logger'
10
+ $LOG = Logger.new(STDOUT)
11
+
12
+ require 'server'
13
+
@@ -0,0 +1,19 @@
1
+ require 'casserver/authenticators/ldap'
2
+
3
+ # Slightly modified version of the LDAP authenticator for Microsoft's ActiveDirectory.
4
+ # The only difference is that the default_username_attribute for AD is 'sAMAccountName'
5
+ # rather than 'uid'.
6
+ class CASServer::Authenticators::ActiveDirectoryLDAP < CASServer::Authenticators::LDAP
7
+ protected
8
+ def default_username_attribute
9
+ "sAMAccountName"
10
+ end
11
+
12
+ def extract_extra_attributes(ldap_entry)
13
+ super(ldap_entry)
14
+ if @extra_attributes["objectGUID"]
15
+ @extra_attributes["guid"] = @extra_attributes["objectGUID"].to_s.unpack("H*").to_s
16
+ end
17
+ ldap_entry
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ require "openssl"
2
+
3
+ module Authlogic
4
+ module CryptoProviders
5
+ # This encryption method is reversible if you have the supplied key. So in order to use this encryption method you must supply it with a key first.
6
+ # In an initializer, or before your application initializes, you should do the following:
7
+ #
8
+ # Authlogic::CryptoProviders::AES256.key = "my really long and unique key, preferrably a bunch of random characters"
9
+ #
10
+ # My final comment is that this is a strong encryption method, but its main weakness is that its reversible. If you do not need to reverse the hash
11
+ # then you should consider Sha512 or BCrypt instead.
12
+ #
13
+ # Keep your key in a safe place, some even say the key should be stored on a separate server.
14
+ # This won't hurt performance because the only time it will try and access the key on the separate server is during initialization, which only
15
+ # happens once. The reasoning behind this is if someone does compromise your server they won't have the key also. Basically, you don't want to
16
+ # store the key with the lock.
17
+ class AES256
18
+ class << self
19
+ attr_writer :key
20
+
21
+ def encrypt(*tokens)
22
+ aes.encrypt
23
+ aes.key = @key
24
+ [aes.update(tokens.join) + aes.final].pack("m").chomp
25
+ end
26
+
27
+ def matches?(crypted, *tokens)
28
+ aes.decrypt
29
+ aes.key = @key
30
+ (aes.update(crypted.unpack("m").first) + aes.final) == tokens.join
31
+ rescue OpenSSL::CipherError
32
+ false
33
+ end
34
+
35
+ private
36
+ def aes
37
+ raise ArgumentError.new("You must provide a key like #{name}.key = my_key before using the #{name}") if @key.blank?
38
+ @aes ||= OpenSSL::Cipher::Cipher.new("AES-256-ECB")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end