Sha256: 840763e72020e054cf332f37b62ffc34b853a808dc5b8ad02f107b5c5021d805

Contents?: true

Size: 1.19 KB

Versions: 25

Compression:

Stored size: 1.19 KB

Contents

# frozen-string-literal: true

module Rodauth
  Feature.define(:password_pepper, :PasswordPepper) do
    depends :login_password_requirements_base

    auth_value_method :password_pepper, nil
    auth_value_method :previous_password_peppers, [""]
    auth_value_method :password_pepper_update?, true

    def password_match?(password)
      if (result = super) && @previous_pepper_matched && password_pepper_update?
        set_password(password)
      end

      result
    end

    private

    def password_hash(password)
      super(password + password_pepper.to_s)
    end

    def password_hash_match?(hash, password)
      return super if password_pepper.nil?

      return true if super(hash, password + password_pepper)

      @previous_pepper_matched = previous_password_peppers.any? do |pepper|
        super(hash, password + pepper)
      end
    end

    def database_function_password_match?(name, hash_id, password, salt)
      return super if password_pepper.nil?

      return true if super(name, hash_id, password + password_pepper, salt)

      @previous_pepper_matched = previous_password_peppers.any? do |pepper|
        super(name, hash_id, password + pepper, salt)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rodauth-2.27.0 lib/rodauth/features/password_pepper.rb
rodauth-2.26.1 lib/rodauth/features/password_pepper.rb
rodauth-2.26.0 lib/rodauth/features/password_pepper.rb
rodauth-2.25.0 lib/rodauth/features/password_pepper.rb
rodauth-2.24.0 lib/rodauth/features/password_pepper.rb
rodauth-2.23.0 lib/rodauth/features/password_pepper.rb
rodauth-2.22.0 lib/rodauth/features/password_pepper.rb
rodauth-2.21.0 lib/rodauth/features/password_pepper.rb
rodauth-2.20.0 lib/rodauth/features/password_pepper.rb
rodauth-2.19.0 lib/rodauth/features/password_pepper.rb
rodauth-2.18.0 lib/rodauth/features/password_pepper.rb
rodauth-2.17.0 lib/rodauth/features/password_pepper.rb
rodauth-2.16.0 lib/rodauth/features/password_pepper.rb
rodauth-2.15.0 lib/rodauth/features/password_pepper.rb
rodauth-2.14.0 lib/rodauth/features/password_pepper.rb
rodauth-2.13.0 lib/rodauth/features/password_pepper.rb
rodauth-2.12.0 lib/rodauth/features/password_pepper.rb
rodauth-2.11.0 lib/rodauth/features/password_pepper.rb
rodauth-2.10.0 lib/rodauth/features/password_pepper.rb
rodauth-2.9.0 lib/rodauth/features/password_pepper.rb