Module: Doorkeeper::OAuth::Helpers::URIChecker

Defined in:
lib/doorkeeper/oauth/helpers/uri_checker.rb

Class Method Summary collapse

Class Method Details

.as_uri(url) ⇒ Object



22
23
24
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 22

def self.as_uri(url)
  URI.parse(url)
end

.matches?(url, client_url) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# 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)
  url.query = nil
  url == client_url
end

.test_uri?(url) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 26

def self.test_uri?(url)
  url == Doorkeeper.configuration.test_redirect_uri
end

.valid?(url) ⇒ Boolean

Returns:

  • (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/doorkeeper/oauth/helpers/uri_checker.rb', line 18

def self.valid_for_authorization?(url, client_url)
  valid?(url) && matches?(url, client_url)
end