Sha256: f3aad079aab12e6e3cae44ee717261a946f3612884decb44bcd4737b53ed0af1

Contents?: true

Size: 984 Bytes

Versions: 10

Compression:

Stored size: 984 Bytes

Contents

module Doorkeeper
  module OAuth
    module Helpers
      module URIChecker
        def self.valid?(url)
          uri = as_uri(url)
          uri.fragment.nil? && !uri.host.nil? && !uri.scheme.nil?
        rescue URI::InvalidURIError
          false
        end

        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

        def self.valid_for_authorization?(url, client_url)
          valid?(url) && client_url.split.any? { |other_url| matches?(url, other_url) }
        end

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

        def self.native_uri?(url)
          url == Doorkeeper.configuration.native_redirect_uri
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.1.0 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.0.1 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-1.4.1 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.0.0 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-1.4.0 lib/doorkeeper/oauth/helpers/uri_checker.rb
doorkeeper-1.3.1 lib/doorkeeper/oauth/helpers/uri_checker.rb