module Doorkeeper::AccessGrantMixin::ClassMethods

def by_token(token)

Returns:
  • (Doorkeeper::AccessGrant, nil) - AccessGrant object or nil

Parameters:
  • token (#to_s) -- token value (any object that responds to `#to_s`)
def by_token(token)
  find_by(token: token.to_s)
end

def generate_code_challenge(code_verifier)

Returns:
  • (#to_s) - An encoded code challenge based on the provided verifier suitable for PKCE validation

Parameters:
  • code_verifier (#to_s) -- a one time use value (any object that responds to `#to_s`)
def generate_code_challenge(code_verifier)
  padded_result = Base64.urlsafe_encode64(Digest::SHA256.digest(code_verifier))
  padded_result.split('=')[0] # Remove any trailing '='
end

def pkce_supported?

def pkce_supported?
  new.pkce_supported?
end

def revoke_all_for(application_id, resource_owner, clock = Time)

Parameters:
  • resource_owner (ActiveRecord::Base) --
  • application_id (Integer) --
def revoke_all_for(application_id, resource_owner, clock = Time)
  where(application_id: application_id,
        resource_owner_id: resource_owner.id,
        revoked_at: nil)
    .update_all(revoked_at: clock.now.utc)
end