summaryrefslogtreecommitdiff
path: root/app/controllers/oauth/mes_controller.rb
blob: 237eea388dae2e09211c8618413e7f041d2e2a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Oauth
  class MesController < ActionController::API
    include ActionController::HttpAuthentication::Token::ControllerMethods
    before_action :authenticate!

    def show
      render json: @claims
    end

    private

    def authenticate!
      @claims = authenticate_with_http_token do |token, _options|
        claims = Token.claims_for(token)
        Token.revoked?(claims[:jti]) ? nil : claims
      end
      request_http_token_authentication if @claims.blank?
    end
  end
end