Sha256: 5b76c2f81f22a22176466361483406749e2fae2d0649605fde4ad98709d6b3f2

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Doorkeeper
  module OAuth
    module ClientCredentials
      class Issuer
        attr_reader :token, :validator, :error

        def initialize(server, validator)
          @server = server
          @validator = validator
        end

        def create(client, scopes, creator = Creator.new)
          if validator.valid?
            @token = create_token(client, scopes, creator)
            @error = :server_error unless @token
          else
            @token = false
            @error = validator.error
          end

          @token
        end

        private

        def create_token(client, scopes, creator)
          context = Authorization::Token.build_context(
            client,
            Doorkeeper::OAuth::CLIENT_CREDENTIALS,
            scopes,
            nil,
          )
          ttl = Authorization::Token.access_token_expires_in(@server, context)

          creator.call(
            client,
            scopes,
            use_refresh_token: false,
            expires_in: ttl,
          )
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
doorkeeper-5.6.6 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.5 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.4 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.3 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.0 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.0.rc2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.6.0.rc1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.4 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.3 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.0 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.0.rc2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.5.0.rc1 lib/doorkeeper/oauth/client_credentials/issuer.rb