Sha256: 6a35e698bdf4d0662e20024b0502622c51652f46afa37a05c6fd67a2ba3bb040
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
module Doorkeeper module OAuth class PreAuthorization include Validations validate :response_type, error: :unsupported_response_type validate :client, error: :invalid_client validate :scopes, error: :invalid_scope validate :redirect_uri, error: :invalid_redirect_uri attr_accessor :server, :client, :response_type, :redirect_uri, :state attr_writer :scope def initialize(server, client, attrs = {}) @server = server @client = client @response_type = attrs[:response_type] @redirect_uri = attrs[:redirect_uri] @scope = attrs[:scope] @state = attrs[:state] end def authorizable? valid? end def scopes Scopes.from_string scope end def scope @scope.presence || server.default_scopes.to_s end def error_response OAuth::ErrorResponse.from_request(self) end private def validate_response_type server.authorization_response_types.include? response_type end def validate_client client.present? end def validate_scopes return true unless scope.present? if client.application.scopes.empty? Helpers::ScopeChecker.valid?(scope, server.scopes) else Helpers::ScopeChecker.valid?(scope, server.scopes & client.application.scopes) end end # TODO: test uri should be matched against the client's one def validate_redirect_uri return false unless redirect_uri.present? Helpers::URIChecker.native_uri?(redirect_uri) || Helpers::URIChecker.valid_for_authorization?(redirect_uri, client.redirect_uri) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems