Module: Doorkeeper::OAuth::Helpers::URIChecker
- Defined in:
- lib/doorkeeper/oauth/helpers/uri_checker.rb
Class Method Summary collapse
- .as_uri(url) ⇒ Object
- .matches?(url, client_url) ⇒ Boolean
- .native_uri?(url) ⇒ Boolean
- .valid?(url) ⇒ Boolean
- .valid_for_authorization?(url, client_url) ⇒ Boolean
Class Method Details
.as_uri(url) ⇒ Object
27 28 29 |
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 27 def self.as_uri(url) URI.parse(url) end |
.matches?(url, client_url) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 12 def self.matches?(url, client_url) url, client_url = as_uri(url), as_uri(client_url) if Doorkeeper.configuration.wildcard_redirect_uri return true if url.to_s =~ /^#{Regexp.escape(client_url.to_s)}/ false else url.query = nil url == client_url end end |
.native_uri?(url) ⇒ Boolean
31 32 33 |
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 31 def self.native_uri?(url) url == Doorkeeper.configuration.native_redirect_uri end |
.valid?(url) ⇒ Boolean
5 6 7 8 9 10 |
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 5 def self.valid?(url) uri = as_uri(url) uri.fragment.nil? && !uri.host.nil? && !uri.scheme.nil? rescue URI::InvalidURIError false end |
.valid_for_authorization?(url, client_url) ⇒ Boolean
23 24 25 |
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 23 def self.(url, client_url) valid?(url) && client_url.split.any? { |other_url| matches?(url, other_url) } end |