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.



672
673
674
# File 'lib/whoosh/app.rb', line 672

def initialize
  @strategies = {}
end

Instance Method Details

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



676
677
678
# File 'lib/whoosh/app.rb', line 676

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

#buildObject



688
689
690
# File 'lib/whoosh/app.rb', line 688

def build
  @strategies.values.first
end

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



680
681
682
# File 'lib/whoosh/app.rb', line 680

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

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



684
685
686
# File 'lib/whoosh/app.rb', line 684

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