Sha256: 6b5f25a00e5c7c7e914ca052908b3e5bf4ff9b0856e66f0c3a4c94d945d7d0ab
Contents?: true
Size: 871 Bytes
Versions: 2
Compression:
Stored size: 871 Bytes
Contents
require 'uri' class RedirectUriValidator < ActiveModel::EachValidator def self.test_redirect_uri Doorkeeper.configuration.test_redirect_uri end def validate_each(record, attribute, value) if value.blank? record.errors.add(attribute, :blank) else value.split.each do |val| uri = ::URI.parse(val) return if test_redirect_uri?(uri) record.errors.add(attribute, :fragment_present) unless uri.fragment.nil? record.errors.add(attribute, :relative_uri) if uri.scheme.nil? || uri.host.nil? record.errors.add(attribute, :has_query_parameter) unless uri.query.nil? end end rescue URI::InvalidURIError record.errors.add(attribute, :invalid_uri) end private def test_redirect_uri?(uri) self.class.test_redirect_uri.present? && uri.to_s == self.class.test_redirect_uri.to_s end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-1.3.0 | app/validators/redirect_uri_validator.rb |
doorkeeper-1.2.0 | app/validators/redirect_uri_validator.rb |