Class: Doorkeeper::OAuth::ErrorResponse
Class Method Summary
collapse
Instance Method Summary
collapse
#build_query, #uri_with_fragment, #uri_with_query
Constructor Details
#initialize(attributes = {}) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
14
15
16
17
18
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 14
def initialize(attributes = {})
@error = OAuth::Error.new(*attributes.values_at(:name, :state))
@redirect_uri = attributes[:redirect_uri]
@response_on_fragment = attributes[:response_on_fragment]
end
|
Class Method Details
.from_request(request, attributes = {}) ⇒ Object
7
8
9
10
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 7
def self.from_request(request, attributes = {})
state = request.state if request.respond_to?(:state)
new(attributes.merge(name: request.error, state: state))
end
|
Instance Method Details
#authenticate_info ⇒ Object
45
46
47
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 45
def authenticate_info
%(Bearer realm="#{realm}", error="#{name}", error_description="#{description}")
end
|
#body ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 20
def body
{
error: name,
error_description: description,
state: state
}.reject { |_, v| v.blank? }
end
|
49
50
51
52
53
54
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 49
def
{ 'Cache-Control' => 'no-store',
'Pragma' => 'no-cache',
'Content-Type' => 'application/json; charset=utf-8',
'WWW-Authenticate' => authenticate_info }
end
|
#redirect_uri ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 37
def redirect_uri
if @response_on_fragment
uri_with_fragment @redirect_uri, body
else
uri_with_query @redirect_uri, body
end
end
|
#redirectable? ⇒ Boolean
32
33
34
35
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 32
def redirectable?
name != :invalid_redirect_uri && name != :invalid_client &&
!URIChecker.native_uri?(@redirect_uri)
end
|
#status ⇒ Object
28
29
30
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 28
def status
:unauthorized
end
|