Class: Authlete::Response::AuthenticationCallbackResponse

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/authlete/response/authentication-callback-response.rb

Overview

Authlete::Response::AuthenticationCallbackResponse class

This class represents a response from an authentication callback endpoint.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#extract_access_token, #extract_boolean_value, #extract_integer_value, #extract_value, #to_rack_response_json, #to_rack_response_www_authenticate

Constructor Details

#initialize(hash = {}) ⇒ AuthenticationCallbackResponse

The constructor which takes a hash that represents a JSON response from an authentication callback endpoint.



37
38
39
40
41
# File 'lib/authlete/response/authentication-callback-response.rb', line 37

def initialize(hash = {})
  @authenticated = extract_boolean_value(hash, :authenticated)
  @subject       = extract_value(hash, :subject)
  @claims        = extract_value(hash, :claims)
end

Instance Attribute Details

#authenticatedObject

True when the end-user has been authenticated (= is a valid user).



27
28
29
# File 'lib/authlete/response/authentication-callback-response.rb', line 27

def authenticated
  @authenticated
end

#claimsObject

Pieces of information about the end-user in JSON format.



33
34
35
# File 'lib/authlete/response/authentication-callback-response.rb', line 33

def claims
  @claims
end

#subjectObject

The unique identifier of the end-user.



30
31
32
# File 'lib/authlete/response/authentication-callback-response.rb', line 30

def subject
  @subject
end

Instance Method Details

#to_rack_responseObject

Generate an array which is usable as a Rack response from this instance.



44
45
46
47
48
49
50
# File 'lib/authlete/response/authentication-callback-response.rb', line 44

def to_rack_response
  to_rack_response_json(200, JSON.generate(
    :authenticated => @authenticated,
    :subject       => @subject,
    :claims        => @claims
  ))
end