Class: Spree::Api::V3::BaseController

Inherits:
ActionController::API
  • Object
show all
Includes:
ActiveStorage::SetCurrent, CanCan::ControllerAdditions, Pagy::Method, ApiKeyAuthentication, ErrorHandler, Idempotent, JwtAuthentication, LocaleAndCurrency, RateLimitHeaders, ResourceSerializer, SecurityHeaders, Core::ControllerHelpers::Store, Core::ControllerHelpers::StrongParameters
Defined in:
app/controllers/spree/api/v3/base_controller.rb

Constant Summary collapse

RATE_LIMIT_RESPONSE =
-> {
  limit = Spree::Api::Config[:rate_limit_per_key]
  window = Spree::Api::Config[:rate_limit_window]
  body = { error: { code: 'rate_limit_exceeded', message: 'Too many requests. Please retry later.' } }
  headers = {
    'Content-Type' => 'application/json',
    'Retry-After' => window.to_s,
    'X-RateLimit-Limit' => limit.to_s,
    'X-RateLimit-Remaining' => '0'
  }
  [429, headers, [body.to_json]]
}

Constants included from Idempotent

Idempotent::IDEMPOTENCY_HEADER, Idempotent::IDEMPOTENCY_TTL, Idempotent::MAX_KEY_LENGTH, Idempotent::MUTATING_METHODS

Constants included from ErrorHandler

ErrorHandler::ERROR_CODES

Constants included from JwtAuthentication

JwtAuthentication::JWT_AUDIENCE_ADMIN, JwtAuthentication::JWT_AUDIENCE_STORE, JwtAuthentication::JWT_ISSUER, JwtAuthentication::USER_TYPE_ADMIN, JwtAuthentication::USER_TYPE_CUSTOMER

Method Summary

Methods included from ApiKeyAuthentication

#authenticate_api_key!, #authenticate_secret_key!

Methods included from JwtAuthentication

#authenticate_user, #require_authentication!