Module: OpenID

Defined in:
lib/gapps_openid.rb

Overview

Extends ruby-openid to support the discovery protocol used by Google Apps. Usage is generally simple. Where using ruby-openid’s Consumer, add the line

require 'gapps_openid'

Caching of discovery information is enabled when used with rails. In other environments, a cache can be set via:

OpenID.cache = ...

The cache must implement methods read(key) and write(key,value)

Similarly, logging will attempt to use the default Rail’s logger, but can be overriden by calling

OpenID.logger = ...

The logger must respond to warn, debug, and info methods

In some cases additional setup is required, particularly to set the location of trusted root certificates for validating XRDS signatures. If standard locations don’t work, additional files and directories can be added via:

OpenID::SimpleSign.store.add_file(path_to_cacert_pem)

or

OpenID::SimpleSign.store.add_path(path_to_ca_dir)

TODO:

  • Memcache support for caching host-meta and site XRDS docs

  • Better packaging (gem/rails)

Defined Under Namespace

Classes: GoogleDiscovery, SimpleSign

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject

Returns the value of attribute cache.



60
61
62
# File 'lib/gapps_openid.rb', line 60

def cache
  @cache
end

.loggerObject

Returns the value of attribute logger.



60
61
62
# File 'lib/gapps_openid.rb', line 60

def logger
  @logger
end

Class Method Details

.default_discoverObject



59
# File 'lib/gapps_openid.rb', line 59

alias_method :default_discover, :discover

.discover(uri) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/gapps_openid.rb', line 63

def self.discover(uri)
  discovery = GoogleDiscovery.new
  info = discovery.perform_discovery(uri)
  if not info.nil?
    OpenID.logger.debug("Discovery info = #{info}") unless OpenID.logger.nil?
    return info
  end
  return self.default_discover(uri)
end