Module: OpenIdAuthentication

Included in:
NormalizeTest, StatusTest
Defined in:
lib/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb,
lib/vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb,
lib/vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb,
lib/vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb,
lib/vendor/plugins/open_id_authentication/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



74
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
# File 'lib/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb', line 74

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



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

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

.storeObject



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

def self.store
  @@store
end

.store=(*store_option) ⇒ Object



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

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