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.



686
687
688
# File 'lib/whoosh/app.rb', line 686

def initialize
  @strategies = {}
end

Instance Method Details

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



690
691
692
# File 'lib/whoosh/app.rb', line 690

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

#buildObject



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

def build
  @strategies.values.first
end

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



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

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

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



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

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