Sha256: 0d54721fb3c7ea2b3f60a0ab49dba327a86463f3b291bf6f450c7f2fc14060b3

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

# :nodoc:
#
# Copyright (C) 2014 Authlete, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


module Authlete
  module Response
    # == Authlete::Response::AuthenticationCallbackResponse class
    #
    # This class represents a response from an authentication callback endpoint.
    class AuthenticationCallbackResponse
      include Authlete::Utility

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

      # The unique identifier of the end-user.
      attr_accessor :subject

      # Pieces of information about the end-user in JSON format.
      attr_accessor :claims

      # The constructor which takes a hash that represents a JSON response
      # from an authentication callback endpoint.
      def initialize(hash = {})
        @authenticated = extract_boolean_value(hash, :authenticated)
        @subject       = extract_value(hash, :subject)
        @claims        = extract_value(hash, :claims)
      end

      # Generate an array which is usable as a Rack response from this instance.
      def to_rack_response
        to_rack_response_json(200, JSON.generate(
          :authenticated => @authenticated,
          :subject       => @subject,
          :claims        => @claims
        ))
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
authlete-0.1.6 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.5 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.4 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.3 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.2 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.1 lib/authlete/response/authentication-callback-response.rb
authlete-0.1.0 lib/authlete/response/authentication-callback-response.rb
authlete-0.0.9 lib/authlete/response/authentication-callback-response.rb
authlete-0.0.8 lib/authlete/response/authentication-callback-response.rb
authlete-0.0.7 lib/authlete/response/authentication-callback-response.rb
authlete-0.0.6 lib/authlete/response/authentication-callback-response.rb
authlete-0.0.5 lib/authlete/response/authentication-callback-response.rb