class Doorkeeper::OAuth::ClientCredentials::Validator

Public Class Methods

new(server, request) click to toggle source
# File lib/doorkeeper/oauth/client_credentials/validator.rb, line 14
def initialize(server, request)
  @server = server
  @request = request
  @client = request.client

  validate
end

Private Instance Methods

validate_client() click to toggle source
# File lib/doorkeeper/oauth/client_credentials/validator.rb, line 24
def validate_client
  @client.present?
end
validate_client_supports_grant_flow() click to toggle source
# File lib/doorkeeper/oauth/client_credentials/validator.rb, line 28
def validate_client_supports_grant_flow
  return if @client.blank?

  Doorkeeper.config.allow_grant_flow_for_client?(
    Doorkeeper::OAuth::CLIENT_CREDENTIALS,
    @client.application,
  )
end
validate_scopes() click to toggle source
# File lib/doorkeeper/oauth/client_credentials/validator.rb, line 37
def validate_scopes
  application_scopes = if @client.present?
                         @client.application.scopes
                       else
                         ""
                       end
  return true if @request.scopes.blank? && application_scopes.blank?

  ScopeChecker.valid?(
    scope_str: @request.scopes.to_s,
    server_scopes: @server.scopes,
    app_scopes: application_scopes,
    grant_type: Doorkeeper::OAuth::CLIENT_CREDENTIALS,
  )
end