Class: Persona::Oidc::StubProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/persona/oidc.rb

Overview

Local / development stand-in for a real provider. Its authorize URL points at an app-local page, and #verify trusts a subject handed straight through the callback params — NO cryptographic verification. It exists so the whole bind / adopt / merge flow can be exercised before any real IdP is wired up. MUST NOT be deployed to production (protocol.md P-16).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: 'stub', authorize_path: '/auth/oidc/start') ⇒ StubProvider

Returns a new instance of StubProvider.



42
43
44
45
# File 'lib/persona/oidc.rb', line 42

def initialize(name: 'stub', authorize_path: '/auth/oidc/start')
  @name = name
  @authorize_path = authorize_path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



40
41
42
# File 'lib/persona/oidc.rb', line 40

def name
  @name
end

Instance Method Details

#authorize(state) ⇒ Object



47
48
49
# File 'lib/persona/oidc.rb', line 47

def authorize(state)
  AuthorizeStart.new(url: "#{@authorize_path}?state=#{CGI.escape(state)}", stash: nil)
end

#verify(params, _stash = nil) ⇒ Object



51
52
53
54
55
56
# File 'lib/persona/oidc.rb', line 51

def verify(params, _stash = nil)
  subject = params[:sub] || params['sub']
  return nil if subject.nil? || subject.to_s.empty?

  Identity.new(provider: name, subject: subject)
end