Files
ruby-sea-battle/main-server/app/controllers/api/internal/base_controller.rb
T

20 lines
593 B
Ruby

module Api
module Internal
# Base class for endpoints intended for the game-server only (never for
# browsers). Authenticated via HMAC of the request body instead of a JWT:
# see InternalSignatureService.
class BaseController < ApplicationController
skip_before_action :authenticate_request!
before_action :authenticate_internal_request!
private
def authenticate_internal_request!
unless InternalSignatureService.valid?(request)
render json: { error: "Unauthorized" }, status: :unauthorized
end
end
end
end
end