Module: OpenIdAuthentication

Included in:
NormalizeTest, StatusTest
Defined in:
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb,
vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb,
vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb,
vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb,
vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb,
vendor/plugins/open_id_authentication/lib/open_id_authentication/mem_cache_store.rb

Defined Under Namespace

Modules: Request Classes: Association, DbStore, InvalidOpenId, MemCacheStore, Nonce, Result

Constant Summary

OPEN_ID_AUTHENTICATION_DIR =
RAILS_ROOT + "/tmp/openids"

Class Method Summary

Class Method Details

+ (Object) normalize_identifier(identifier)

normalizes an OpenID according to http://openid.net/specs/openid-authentication-2_0.html#normalization



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'vendor/plugins/open_id_authentication/lib/open_id_authentication.rb', line 75

def self.normalize_identifier(identifier)
  # clean up whitespace
  identifier = identifier.to_s.strip

  # if an XRI has a prefix, strip it.
  identifier.gsub!(/xri:\/\//i, '')

  # dodge XRIs -- TODO: validate, don't just skip.
  unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
    # does it begin with http?  if not, add it.
    identifier = "http://#{identifier}" unless identifier =~ /^http/i

    # strip any fragments
    identifier.gsub!(/\#(.*)$/, '')

    begin
      uri = URI.parse(identifier)
      uri.scheme = uri.scheme.downcase  # URI should do this
      identifier = uri.normalize.to_s
    rescue URI::InvalidURIError
      raise InvalidOpenId.new("#{identifier} is not an OpenID identifier")
    end
  end

  return identifier
end

+ (Object) normalize_url(url)

deprecated for OpenID 2.0, where not all OpenIDs are URLs



103
104
105
106
# File 'vendor/plugins/open_id_authentication/lib/open_id_authentication.rb', line 103

def self.normalize_url(url)
  ActiveSupport::Deprecation.warn "normalize_url has been deprecated, use normalize_identifier instead"
  self.normalize_identifier(url)
end

+ (Object) store



14
15
16
# File 'vendor/plugins/open_id_authentication/lib/open_id_authentication.rb', line 14

def self.store
  @@store
end

+ (Object) store=(*store_option)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'vendor/plugins/open_id_authentication/lib/open_id_authentication.rb', line 18

def self.store=(*store_option)
  store, *parameters = *([ store_option ].flatten)

  @@store = case store
  when :db
    OpenIdAuthentication::DbStore.new
  when :mem_cache
    OpenIdAuthentication::MemCacheStore.new(*parameters)
  when :file
    OpenID::Store::Filesystem.new(OPEN_ID_AUTHENTICATION_DIR)
  else
    raise "Unknown store: #{store}"
  end
end