module Doorkeeper::Models::SecretStorable::ClassMethods
:nodoc
Public Instance Methods
fallback_secret_strategy()
click to toggle source
Determine the fallback storing strategy Unless configured, there will be no fallback
# File lib/doorkeeper/models/concerns/secret_storable.rb, line 100 def fallback_secret_strategy nil end
find_by_fallback_token(attr, plain_secret)
click to toggle source
Allow looking up previously plain tokens as a fallback IFF a fallback strategy has been defined
@param attr [Symbol]
The token attribute we're looking with.
@param plain_secret [#to_s]
plain secret value (any object that responds to `#to_s`)
@return [Doorkeeper::AccessToken, nil] AccessToken
object or nil
if there is no record with such token
# File lib/doorkeeper/models/concerns/secret_storable.rb, line 61 def find_by_fallback_token(attr, plain_secret) return nil unless fallback_secret_strategy # Use the previous strategy to look up stored_token = fallback_secret_strategy.transform_secret(plain_secret) find_by(attr => stored_token).tap do |resource| return nil unless resource upgrade_fallback_value resource, attr, plain_secret end end
find_by_plaintext_token(attr, token)
click to toggle source
Returns an instance of the Doorkeeper::AccessToken
with specific token value.
@param attr [Symbol]
The token attribute we're looking with.
@param token [#to_s]
token value (any object that responds to `#to_s`)
@return [Doorkeeper::AccessToken, nil] AccessToken
object or nil
if there is no record with such token
# File lib/doorkeeper/models/concerns/secret_storable.rb, line 42 def find_by_plaintext_token(attr, token) token = token.to_s find_by(attr => secret_strategy.transform_secret(token)) || find_by_fallback_token(attr, token) end
secret_strategy()
click to toggle source
Determines the secret storing transformer Unless configured otherwise, uses the plain secret strategy
# File lib/doorkeeper/models/concerns/secret_storable.rb, line 93 def secret_strategy ::Doorkeeper::SecretStoring::Plain end
upgrade_fallback_value(instance, attr, plain_secret)
click to toggle source
Allow implementations in ORMs to replace a plain value falling back to to avoid it remaining as plain text.
@param instance
An instance of this model with a plain value token.
@param attr
The secret attribute name to upgrade.
@param plain_secret
The plain secret to upgrade.
# File lib/doorkeeper/models/concerns/secret_storable.rb, line 85 def upgrade_fallback_value(instance, attr, plain_secret) upgraded = secret_strategy.store_secret(instance, attr, plain_secret) instance.update(attr => upgraded) end