Module: OpenIdAuthentication
- Included in:
- NormalizeTest, StatusTest
- Defined in:
- lib/plugins/open_id_authentication/lib/open_id_authentication/request.rb,
lib/plugins/open_id_authentication/lib/open_id_authentication.rb,
lib/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb,
lib/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb,
lib/plugins/open_id_authentication/lib/open_id_authentication/association.rb,
lib/plugins/open_id_authentication/lib/open_id_authentication/mem_cache_store.rb
Overview
frozen_string_literal: false
Defined Under Namespace
Modules: Request Classes: Association, DbStore, InvalidOpenId, MemCacheStore, Nonce, Result
Class Method Summary collapse
- .new(app) ⇒ Object
-
.normalize_identifier(identifier) ⇒ Object
normalizes an OpenID according to openid.net/specs/openid-authentication-2_0.html#normalization.
- .store ⇒ Object
- .store=(*store_option) ⇒ Object
Class Method Details
.new(app) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/plugins/open_id_authentication/lib/open_id_authentication.rb', line 6 def self.new(app) store = OpenIdAuthentication.store if store.nil? Rails.logger.warn "OpenIdAuthentication.store is nil. Using in-memory store." end ::Rack::OpenID.new(app, OpenIdAuthentication.store) end |
.normalize_identifier(identifier) ⇒ Object
normalizes an OpenID according to openid.net/specs/openid-authentication-2_0.html#normalization
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/plugins/open_id_authentication/lib/open_id_authentication.rb', line 80 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 /^http/i.match?(identifier) # strip any fragments identifier.gsub!(/\#(.*)$/, '') begin uri = URI.parse(identifier) uri.scheme = uri.scheme.downcase if uri.scheme # 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 |
.store ⇒ Object
15 16 17 |
# File 'lib/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 31 32 33 34 35 36 |
# File 'lib/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 :memory require 'openid/store/memory' OpenID::Store::Memory.new when :file require 'openid/store/filesystem' OpenID::Store::Filesystem.new(Rails.root.join('tmp/openids')) when :memcache require 'memcache' require 'openid/store/memcache' OpenID::Store::Memcache.new(MemCache.new(parameters)) else store end end |