Class: Doorkeeper::TokensController

Inherits:
ApplicationMetalController show all
Defined in:
app/controllers/doorkeeper/tokens_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
# File 'app/controllers/doorkeeper/tokens_controller.rb', line 7

def create
  headers.merge!(authorize_response.headers)
  render json: authorize_response.body,
         status: authorize_response.status
rescue Errors::DoorkeeperError => e
  handle_token_exception(e)
end

#introspectObject

OAuth 2.0 Token Introspection - datatracker.ietf.org/doc/html/rfc7662



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/doorkeeper/tokens_controller.rb', line 34

def introspect
  introspection = OAuth::TokenIntrospection.new(server, token)

  if introspection.authorized?
    render json: introspection.to_json, status: 200
  else
    error = introspection.error_response
    headers.merge!(error.headers)
    render json: error.body, status: error.status
  end
end

#revokeObject

OAuth 2.0 Token Revocation - datatracker.ietf.org/doc/html/rfc7009



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/doorkeeper/tokens_controller.rb', line 16

def revoke
  # The authorization server responds with HTTP status code 200 if the client
  # submitted an invalid token or the token has been revoked successfully.
  if token.blank?
    render json: {}, status: 200
  # The authorization server validates [...] and whether the token
  # was issued to the client making the revocation request. If this
  # validation fails, the request is refused and the client is informed
  # of the error by the authorization server as described below.
  elsif authorized?
    revoke_token
    render json: {}, status: 200
  else
    render json: revocation_error_response, status: :forbidden
  end
end