Class: ThreeScale::Backend::Validators::RedirectURI

Inherits:
Base
  • Object
show all
Defined in:
lib/3scale/backend/validators/redirect_uri.rb

Constant Summary collapse

REDIRECT_URL =

This should’ve been named redirect_uri as per OAuth specs, but was initially named redirect_url. We check both fields, prioritizing the contents in the legacy redirect_url parameter over the “new” redirect_uri one.

'redirect_url'.freeze
REDIRECT_URI =
'redirect_uri'.freeze

Instance Attribute Summary

Attributes inherited from Base

#params, #status

Instance Method Summary collapse

Methods inherited from Base

#application, apply, #fail!, #initialize, #service, #succeed!

Constructor Details

This class inherits a constructor from ThreeScale::Backend::Validators::Base

Instance Method Details

#applyObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/3scale/backend/validators/redirect_uri.rb', line 12

def apply
  invalid_exception = RedirectURIInvalid
  redirect_uri = if params.has_key? REDIRECT_URL
                   invalid_exception = RedirectURLInvalid
                   params[REDIRECT_URL]
                 elsif params.has_key? REDIRECT_URI
                   status.redirect_uri_field = REDIRECT_URI
                   params[REDIRECT_URI]
                 else
                   nil
                 end

  if redirect_uri.nil? || redirect_uri.empty? || application.redirect_url == redirect_uri
    succeed!
  else
    fail!(invalid_exception.new redirect_uri)
  end
end