Module: OpenIdAuthentication

Defined in:
lib/openid_auth.rb,
lib/open_id_authentication/nonce.rb,
lib/open_id_authentication/request.rb,
lib/open_id_authentication/db_store.rb,
lib/open_id_authentication/association.rb

Defined Under Namespace

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

Constant Summary collapse

OPEN_ID_AUTHENTICATION_DIR =
RAILS_ROOT + "/tmp/openids"

Class Method Summary collapse

Class Method Details

.normalize_identifier(identifier) ⇒ Object



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 'lib/openid_auth.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

.normalize_url(url) ⇒ Object

deprecated for OpenID 2.0, where not all OpenIDs are URLs



103
104
105
106
# File 'lib/openid_auth.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

.storeObject



16
17
18
# File 'lib/openid_auth.rb', line 16

def self.store
  @@store
end

.store=(*store_option) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/openid_auth.rb', line 20

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

  @@store = case store
  when :db
    OpenIdAuthentication::DbStore.new
  when :file
    OpenID::Store::Filesystem.new(OPEN_ID_AUTHENTICATION_DIR)
  else
    store
  end
end