Class: Rack::OAuth2::Server::Authorize::Request

Inherits:
Rack::OAuth2::Server::Abstract::Request show all
Includes:
Extension::ResponseMode::AuthorizationRequest
Defined in:
lib/rack/oauth2/server/authorize.rb

Direct Known Subclasses

Code::Request, Token::Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Extension::ResponseMode::AuthorizationRequest

included

Methods inherited from Rack::OAuth2::Server::Abstract::Request

#attr_missing!

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



43
44
45
46
47
48
49
50
# File 'lib/rack/oauth2/server/authorize.rb', line 43

def initialize(env)
  super
  # NOTE: Raise before redirect_uri is saved not to redirect back to unverified redirect_uri.
  invalid_request! '"client_id" missing' if client_id.blank?
  @redirect_uri = Util.parse_uri(params['redirect_uri']) if params['redirect_uri']
  @response_mode = params['response_mode']
  @state = params['state']
end

Instance Attribute Details

#verified_redirect_uriObject

Returns the value of attribute verified_redirect_uri.



41
42
43
# File 'lib/rack/oauth2/server/authorize.rb', line 41

def verified_redirect_uri
  @verified_redirect_uri
end

Instance Method Details

#error_params_locationObject



74
75
76
# File 'lib/rack/oauth2/server/authorize.rb', line 74

def error_params_location
  nil # => All errors are raised immediately and no error response are returned to client.
end

#verify_redirect_uri!(pre_registered, allow_partial_match = false) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rack/oauth2/server/authorize.rb', line 52

def verify_redirect_uri!(pre_registered, allow_partial_match = false)
  @verified_redirect_uri = if redirect_uri.present?
    verified = Array(pre_registered).any? do |_pre_registered_|
      if allow_partial_match
        Util.uri_match?(_pre_registered_, redirect_uri)
      else
        _pre_registered_.to_s == redirect_uri.to_s
      end
    end
    if verified
      redirect_uri
    else
      invalid_request! '"redirect_uri" mismatch'
    end
  elsif pre_registered.present? && Array(pre_registered).size == 1 && !allow_partial_match
    Array(pre_registered).first
  else
    invalid_request! '"redirect_uri" missing'
  end
  self.verified_redirect_uri.to_s
end