Sha256: 4d397563513d66dc317af99ec96754cb5f30d3ec03faaa102ec8d58f57f069ff

Contents?: true

Size: 1018 Bytes

Versions: 5

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  module DeviceAuthorizationGrant
    module Request
      # Doorkeeper strategy for OAuth 2.0 Device Authorization Requests.
      #
      # @see https://tools.ietf.org/html/rfc8628#section-3.1 RFC 8628, sect. 3.1
      class DeviceAuthorization < ::Doorkeeper::Request::Strategy
        delegate :client, :parameters, to: :server

        # @return [OAuth::DeviceAuthorizationRequest]
        def request
          @request ||= OAuth::DeviceAuthorizationRequest.new(
            Doorkeeper.configuration,
            client,
            host_name,
            parameters
          )
        end

        private

        # @return [String]
        def host_name
          req = server.context.request
          "#{req.scheme}://#{req.host}#{port}"
        end

        # @return [String, nil]
        def port
          return nil if [80, 443].include?(server.context.request.port)

          ":#{server.context.request.port}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-device_authorization_grant-1.0.3 lib/doorkeeper/device_authorization_grant/request/device_authorization.rb
doorkeeper-device_authorization_grant-1.0.2 lib/doorkeeper/device_authorization_grant/request/device_authorization.rb
doorkeeper-device_authorization_grant-1.0.1 lib/doorkeeper/device_authorization_grant/request/device_authorization.rb
doorkeeper-device_authorization_grant-1.0.0 lib/doorkeeper/device_authorization_grant/request/device_authorization.rb
doorkeeper-device_authorization_grant-0.2.1 lib/doorkeeper/device_authorization_grant/request/device_authorization.rb