Class: Rubino::API::Operations::OAuth::Connections::DisconnectOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/api/operations/oauth/connections/disconnect_operation.rb

Overview

DELETE /v1/oauth/connections/:id Removes a stored OAuth connection (encrypted tokens included) and asks the provider to revoke the underlying token, so a DB dump + encryption-key compromise no longer yields indefinite provider-side access.

Provider revoke is best-effort: a failure (network, 4xx) is logged and the local row is still destroyed — leaving a stale local row is strictly worse than missing the revoke, since the user thinks the connection is gone and we’d keep using the encrypted tokens.

Returns:

  • ([Integer, nil])

    204 No Content.

Raises:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository: nil, registry: ::Rubino::OAuth::Registry, logger: nil) ⇒ DisconnectOperation

Accepts an alternate repository / registry / logger for tests.



27
28
29
30
31
# File 'lib/rubino/api/operations/oauth/connections/disconnect_operation.rb', line 27

def initialize(repository: nil, registry: ::Rubino::OAuth::Registry, logger: nil)
  @repository = repository
  @registry = registry
  @logger = logger
end

Class Method Details

.call(request) ⇒ Object



22
23
24
# File 'lib/rubino/api/operations/oauth/connections/disconnect_operation.rb', line 22

def self.call(request)
  new.call(request)
end

Instance Method Details

#call(request) ⇒ Object

Raises:



33
34
35
36
37
38
39
40
41
# File 'lib/rubino/api/operations/oauth/connections/disconnect_operation.rb', line 33

def call(request)
  id = request.params.fetch("id")
  connection = repository.find(id)
  raise NotFoundError.new("oauth_connection", id) unless connection

  revoke_remote(connection)
  repository.destroy!(id)
  [204, nil]
end