Sha256: a36581f7844637a3989115ccf7e4820e7cb7cea232e7c726bf177375522186d4
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
require 'uri' class RedirectUriValidator < ActiveModel::EachValidator def self.native_redirect_uri Doorkeeper.configuration.native_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 native_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 native_redirect_uri?(uri) self.class.native_redirect_uri.present? && uri.to_s == self.class.native_redirect_uri.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-1.3.1 | app/validators/redirect_uri_validator.rb |