class Authlete::Model::Response::IntrospectionResponse
Attributes
Public Instance Methods
Source
# File lib/authlete/model/response/introspection-response.rb, line 127 def to_rack_response # 'action' denotes the next action. case @action when 'INTERNAL_SERVER_ERROR' # 500 Internal Server Error # The API request from this implementation was wrong # or an error occurred in Authlete. return to_rack_response_www_authenticate(500, @response_content) when 'BAD_REQUEST' # 400 Bad Request # The request from the client application does not # contain an access token. return to_rack_response_www_authenticate(400, @response_content) when 'UNAUTHORIZED' # 401 Unauthorized # The presented access token does not exist or has expired. return to_rack_response_www_authenticate(401, @response_content) when 'FORBIDDEN' # 403 Forbidden # The access token does not cover the required scopes # or the subject associated with the access token is # different. return to_rack_response_www_authenticate(403, @response_content) when 'OK' # The access token is valid (= exists and has not expired). # Basically, the caller won't use the array returned from here. # Instead, it will return the protected resource to the client # application which has presented the valid access token. return [ 200, nil, nil ] else # This should not happen. return to_rack_response_www_authenticate(500, 'Bearer error="server_error",error_description="Unknown action"') end end
Generate an array which is usable as a Rack response from this instance. When action
method returns other value than ‘OK’, the array returned from this method satisfies RFC 6750.
Private Instance Methods
Source
# File lib/authlete/model/response/introspection-response.rb, line 80 def defaults super.merge( action: nil, clientId: 0, clientIdAlias: nil, clientIdAliasUsed: false, expiresAt: 0, subject: nil, scopes: nil, existent: false, usable: false, sufficient: false, refreshable: false, responseContent: nil, properties: nil, certificateThumbprint: nil, resources: nil, accessTokenResources: nil ) end
Calls superclass method
Authlete::Model::Result#defaults
Source
# File lib/authlete/model/response/introspection-response.rb, line 101 def set_params(hash) super(hash) @action = hash[:action] @clientId = hash[:clientId] @clientIdAlias = hash[:clientIdAlias] @clientIdAliasUsed = hash[:clientIdAliasUsed] @expiresAt = hash[:expiresAt] @subject = hash[:subject] @scopes = hash[:scopes] @existent = hash[:existent] @usable = hash[:usable] @sufficient = hash[:sufficient] @refreshable = hash[:refreshable] @responseContent = hash[:responseContent] @properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) } @certificateThumbprint = hash[:certificateThumbprint] @resources = hash[:resources] @accessTokenResources = hash[:accessTokenResources] end
Calls superclass method
Authlete::Model::Result#set_params