Changesets can be listed by changeset number.
The Git repository is here.
Changeset 330
Updated Hub gem to version 0.2.7.
- Comitted by: rool
- Date: Saturday March 19 17:04:30 2011 (over 13 years ago)
Affected files:
- rool/rails/gems/hubssolib/trunk/VERSION (diff)
- rool/rails/gems/hubssolib/trunk/hubssolib.gemspec (diff)
- rool/rails/gems/hubssolib/trunk/lib/hub_sso_lib.rb (diff)
rool/rails/gems/hubssolib/trunk/VERSION:
prev. | current | |
1 | ||
1 | 0.2.7 (05-Mar-2011) |
rool/rails/gems/hubssolib/trunk/hubssolib.gemspec:
prev. | current | |
s.platform = Gem::Platform::RUBY | ||
s.name = 'hubssolib' | ||
7 | | |
7 | s.version = '0.2.7' | |
s.author = 'Andrew Hodgkinson and others' | ||
s.email = 'ahodgkin@rowing.org.uk' | ||
10 | | |
10 | s.homepage = 'http://hub.pond.org.uk/' | |
s.date = File.ctime('VERSION') | ||
s.summary = 'Cross-application single sign-on support library.' | ||
... | ... | |
s.files = FileList['lib/**/*.rb', '[A-Z]*'].to_a | ||
s.has_rdoc = false # Sorry, no RDoc documentation yet | ||
26 | | |
26 | s.required_ruby_version = '>= 1.8.7' # Not tested on earlier versions | |
end |
rool/rails/gems/hubssolib/trunk/lib/hub_sso_lib.rb:
prev. | current | |
####################################################################### | ||
# Module: HubSsoLib # | ||
3 | ||
3 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Cross-application same domain single sign-on support. # | ||
# # | ||
... | ... | |
# split from Hub application. # | ||
# 08-Dec-2006 (ADH): DRB URI, path prefix and random file # | ||
# path come from environment variables. # | ||
13 | # 09-Mar-2011 (ADH): Updated for Hub on Rails 2.3.11 along # | |
14 | # with several important bug fixes. # | |
####################################################################### | ||
module HubSsoLib | ||
... | ... | |
####################################################################### | ||
# Class: Crypto # | ||
54 | | |
56 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Encryption and decryption utilities. # | ||
# # | ||
... | ... | |
####################################################################### | ||
# Class: Roles # | ||
302 | | |
304 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Shared methods for handling user account roles. # | ||
# # | ||
... | ... | |
####################################################################### | ||
# Class: Permissions # | ||
462 | | |
464 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Methods to help, in conjunction with Roles, determine the # | ||
# access permissions a particular user is granted. # | ||
... | ... | |
####################################################################### | ||
# Class: User # | ||
522 | | |
524 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: A representation of the Hub application's User Model in # | ||
# terms of a simple set of properties, so that applications # | ||
... | ... | |
####################################################################### | ||
class User | ||
534 | | |
537 | # This *must not* be 'undumped', since it gets passed from clients | |
538 | # back to the persistent DRb server process. A client thread may | |
539 | # disappear and be recreated by the web server at any time; if the | |
540 | # user object is undumpable, then the DRb server has to *call back | |
541 | # to the client* (in DRb, clients are also servers...!) to find out | |
542 | # about the object. Trouble is, if the client thread has been | |
543 | # recreated, the server will be trying to access to stale objects | |
544 | # that only exist if the garbage collector hasn't got to them yet. | |
545 | ||
attr_accessor :user_salt | ||
attr_accessor :user_roles | ||
attr_accessor :user_updated_at | ||
... | ... | |
####################################################################### | ||
# Class: Session # | ||
573 | | |
583 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Session support object, used to store session metadata in # | ||
# an insecure cross-application cookie. # | ||
... | ... | |
####################################################################### | ||
class Session | ||
594 | ||
595 | # Unlike a User, this *is* undumpable since it only gets passed from | |
596 | # server to client. The server's always here to service requests | |
597 | # from the client and used sessions are never garbage collected | |
598 | # since the DRb server's front object, a SessionFactory, keeps them | |
599 | # in a hash held within an instance variable. | |
600 | ||
include DRb::DRbUndumped | ||
attr_accessor :session_last_used | ||
... | ... | |
####################################################################### | ||
# Class: SessionFactory # | ||
601 | | |
618 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Build Session objects for DRb server clients. Maintains a # | ||
# hash of Session objects. # | ||
... | ... | |
####################################################################### | ||
# Module: Server # | ||
631 | | |
648 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: DRb server to provide shared data across applications. # | ||
# Thanks to RubyPanther, rubyonrails IRC, for suggesting # | ||
... | ... | |
module Server | ||
def hubssolib_launch_server | ||
647 | | |
664 | @@session_factory = HubSsoLib::SessionFactory.new | |
665 | DRb.start_service(HUBSSOLIB_DRB_URI, @@session_factory) | |
DRb.thread.join | ||
end | ||
end # Server module | ||
... | ... | |
# Main after_filter method to tidy up after running state changes. | ||
# | ||
def hubssolib_afterwards | ||
867 | | |
885 | begin | |
886 | DRb.current_server | |
887 | DRb.stop_service() | |
888 | rescue DRb::DRbServerNotFound | |
889 | # Nothing to do; no service is running. | |
890 | end | |
end | ||
# Store the URI of the current request in the session, or store the | ||
... | ... | |
def hubssolib_store_location(uri_str = request.request_uri) | ||
if (uri_str && !uri_str.empty?) | ||
878 | | |
901 | uri_str = hubssolib_promote_uri_to_ssl(uri_str, request.host) unless request.ssl? | |
hubssolib_set_return_to(uri_str) | ||
else | ||
hubssolib_set_return_to(nil) | ||
... | ... | |
url = hubssolib_get_return_to | ||
hubssolib_set_return_to(nil) | ||
892 | | |
915 | redirect_to(url || default) | |
end | ||
# Take a URI and pass an optional host parameter. Decomposes the URI, | ||
... | ... | |
# string. | ||
# | ||
def hubssolib_get_exception_message(id_data) | ||
1006 | | |
1029 | hubssolib_get_exception_data(CGI::unescape(id_data)) | |
end | ||
# Inclusion hook to make various methods available as ActionView | ||
... | ... | |
# Establish a single DRb factory connection. | ||
# | ||
def hubssolib_factory | ||
1125 | | |
1126 | | |
1127 | | |
1148 | ||
1149 | # See: | |
1150 | # http://stackoverflow.com/questions/299219/where-is-the-correct-place-to-initialize-the-drb-service-within-a-rails-applicati | |
1151 | # | |
1152 | begin | |
1153 | DRb.current_server | |
1154 | rescue DRb::DRbServerNotFound | |
1155 | DRb.start_service | |
1156 | # Move to different ThreadGroup to stop Mongrel hang on exit. | |
1157 | ThreadGroup.new.add DRb.thread | |
end | ||
1129 | | |
1130 | | |
1159 | ||
1160 | return @factory ||= DRbObject.new_with_uri(HUBSSOLIB_DRB_URI) | |
end | ||
# Retrieve user data from the DRb server. | ||
... | ... | |
# At this point there tends to be no Session data, so we're | ||
# going to have to encode the exception data into the URI... | ||
1198 | # It must be escaped twice, as many servers treat "%2F" in a | |
1199 | # URI as a "/" and Apache may flat refuse to serve the page, | |
1200 | # raising a 404 error unless "AllowEncodedSlashes on" is | |
1201 | # specified in its configuration. | |
1169 | | |
1203 | suffix = '/' + CGI::escape(CGI::escape(hubssolib_set_exception_data(e))) | |
new_path = HUB_PATH_PREFIX + '/tasks/service' | ||
redirect_to new_path + suffix unless request.path.include?(new_path) | ||
return nil | ||
... | ... | |
# At this point there tends to be no Session data, so we're | ||
# going to have to encode the exception data into the URI... | ||
1236 | # See earlier for double-escaping rationale. | |
1203 | | |
1238 | suffix = '/' + CGI::escape(CGI::escape(hubssolib_set_exception_data(e))) | |
new_path = HUB_PATH_PREFIX + '/tasks/service' | ||
redirect_to new_path + suffix unless request.path.include?(new_path) | ||
return nil | ||
... | ... | |
####################################################################### | ||
# Classes: Standard class extensions for HubSsoLib Roles operations. # | ||
1253 | ||
1288 | # (C) Hipposoft 2006 # | |
# # | ||
# Purpose: Extensions to standard classes to support HubSsoLib. # | ||
# # |