Module: OpenIdAuthentication

Defined in:
lib/open_id_authentication.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



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

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

  case OpenID::Yadis::XRI.identifier_scheme(identifier)
  when :xri
    identifier.gsub!(/xri:\/\//i, '')
  else
    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



100
101
102
103
# File 'lib/open_id_authentication.rb', line 100

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/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/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