Class: Whoosh::App::AuthBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/whoosh/app.rb

Overview

— DSL Builders —

Instance Method Summary collapse

Constructor Details

#initializeAuthBuilder

Returns a new instance of AuthBuilder.



693
694
695
# File 'lib/whoosh/app.rb', line 693

def initialize
  @strategies = {}
end

Instance Method Details

#api_key(header: "X-Api-Key", keys: {}) ⇒ Object



697
698
699
# File 'lib/whoosh/app.rb', line 697

def api_key(header: "X-Api-Key", keys: {})
  @strategies[:api_key] = Auth::ApiKey.new(keys: keys, header: header)
end

#buildObject



709
710
711
# File 'lib/whoosh/app.rb', line 709

def build
  @strategies.values.first
end

#jwt(secret:, algorithm: :hs256, expiry: 3600) ⇒ Object



701
702
703
# File 'lib/whoosh/app.rb', line 701

def jwt(secret:, algorithm: :hs256, expiry: 3600)
  @strategies[:jwt] = Auth::Jwt.new(secret: secret, algorithm: algorithm, expiry: expiry)
end

#oauth2(provider: :custom, **opts) ⇒ Object



705
706
707
# File 'lib/whoosh/app.rb', line 705

def oauth2(provider: :custom, **opts)
  @strategies[:oauth2] = Auth::OAuth2.new(provider: provider, **opts)
end