class Doorkeeper::SecretStoring::BCrypt
other secret storing mechanisms are enabled.
but also provides fallback lookup if
Plain text secret storing, which is the default
#
def self.allows_restoring_secrets?
secrets from the database. This allows detecting users
Determines whether this strategy supports restoring
#
def self.allows_restoring_secrets? false end
def self.bcrypt_present?
#
def self.bcrypt_present? require "bcrypt" true rescue LoadError false end
def self.secret_matches?(input, stored)
Securely compare the given +input+ value with a +stored+ value
#
def self.secret_matches?(input, stored) ::BCrypt::Password.new(stored.to_s) == input.to_s rescue ::BCrypt::Errors::InvalidHash false end
def self.transform_secret(plain_secret)
-
plain_secret
() -- The plain secret input / generated
def self.transform_secret(plain_secret) ::BCrypt::Password.create(plain_secret.to_s) end
def self.validate_for(model)
#
def self.validate_for(model) unless model.to_sym == :application raise ArgumentError, "'#{name}' can only be used for storing application secrets." end unless bcrypt_present? raise ArgumentError, "'#{name}' requires the 'bcrypt' gem being loaded." end true end