Sha256: a2e8787c67236a011fe389f079f4bbde3a7e224d5c3c244942c95fe3a5e62182

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

require "knock/engine"

module Knock

  mattr_accessor :handle_attr
  self.handle_attr = :email

  mattr_accessor :current_user_from_handle
  self.current_user_from_handle = -> handle { User.find_by! Knock.handle_attr => handle }

  mattr_accessor :current_user_from_token
  self.current_user_from_token = -> claims { User.find claims['sub'] }

  mattr_accessor :token_lifetime
  self.token_lifetime = 1.day

  mattr_accessor :token_audience
  self.token_audience = nil

  mattr_accessor :token_signature_algorithm
  self.token_signature_algorithm = 'HS256'

  mattr_accessor :token_secret_signature_key
  self.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }

  mattr_accessor :token_public_key
  self.token_public_key = nil

  # Default way to setup Knock. Run `rails generate knock:install` to create
  # a fresh initializer with all configuration values.
  def self.setup
    yield self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knock-1.4.2 lib/knock.rb
knock-1.4.1 lib/knock.rb
knock-1.4.0 lib/knock.rb