Class: Rubino::API::Operations::OAuth::Providers::ConnectOperation

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

Overview

POST /v1/oauth/providers/:id/connect

Builds a PKCE authorize request for the provider and returns { authorize_url, state, code_verifier, provider }. The client persists state + code_verifier between connect and callback; rubino stays stateless on the OAuth flow itself.

Raises:

Instance Method Summary collapse

Constructor Details

#initialize(registry: ::Rubino::OAuth::Registry) ⇒ ConnectOperation

Accepts an alternate provider registry for tests.



19
20
21
# File 'lib/rubino/api/operations/oauth/providers/connect_operation.rb', line 19

def initialize(registry: ::Rubino::OAuth::Registry)
  @registry = registry
end

Instance Method Details

#call(request) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rubino/api/operations/oauth/providers/connect_operation.rb', line 23

def call(request)
  id = request.params.fetch("id")
  provider = @registry.fetch(id)
  attrs = request.validate!(Schemas::ConnectProvider)

  flow = provider.build_authorize_request(
    redirect_uri: attrs[:redirect_uri],
    scopes: attrs[:scopes]
  )

  [200, flow.merge(provider: provider.id)]
end