module DoorkeeperMongodb::Mixins::Mongoid::AccessGrantMixin::ClassMethods
Public Instance Methods
Searches for Doorkeeper::AccessGrant
record with the specific token value.
@param token [#to_s] token value (any object that responds to `#to_s`)
@return [Doorkeeper::AccessGrant, nil] AccessGrant object or nil
if there is no record with such token
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 71 def by_token(token) find_by_plaintext_token(:token, token) end
Determine the fallback storing strategy Unless configured, there will be no fallback
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 146 def fallback_secret_strategy ::Doorkeeper.config.token_secret_fallback_strategy end
@param code_verifier [#to_s] a one time use value (any object that responds to `#to_s`)
@return [#to_s] An encoded code challenge based on the provided verifier suitable for PKCE validation
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 127 def generate_code_challenge(code_verifier) padded_result = Base64.urlsafe_encode64(Digest::SHA256.digest(code_verifier)) padded_result.split("=")[0] # Remove any trailing '=' end
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 132 def pkce_supported? new.pkce_supported? end
Revokes AccessGrant records that have not been revoked and associated with the specific Application and Resource Owner.
@param application_id [Integer]
ID of the Application
@param resource_owner [Mongoid::Document, Integer]
instance of the Resource Owner model
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 83 def revoke_all_for(application_id, resource_owner, clock = Time) by_resource_owner(resource_owner) .where(application_id: application_id, revoked_at: nil) .update_all(revoked_at: clock.now.utc) end
Determines the secret storing transformer Unless configured otherwise, uses the plain secret strategy
# File lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb, line 139 def secret_strategy ::Doorkeeper.config.token_secret_strategy end