class Doorkeeper::OAuth::Token
Public Class Methods
Source
# File lib/doorkeeper/oauth/token.rb, line 15 def authenticate(request, *methods) if (token = from_request(request, *methods)) access_token = Doorkeeper.config.access_token_model.by_token(token) if access_token.present? && Doorkeeper.config.refresh_token_enabled? access_token.revoke_previous_refresh_token! end access_token end end
Source
# File lib/doorkeeper/oauth/token.rb, line 25 def from_access_token_param(request) request.parameters[:access_token] end
Source
# File lib/doorkeeper/oauth/token.rb, line 29 def from_bearer_param(request) request.parameters[:bearer_token] end
Source
# File lib/doorkeeper/oauth/token.rb, line 7 def from_request(request, *methods) methods.inject(nil) do |_, method| method = self.method(method) if method.is_a?(Symbol) credentials = method.call(request) break credentials if credentials.present? end end
Private Class Methods
Source
# File lib/doorkeeper/oauth/token.rb, line 52 def decode_basic_credentials_token(encoded_header) Base64.decode64(encoded_header).split(/:/, 2).first end
Source
# File lib/doorkeeper/oauth/token.rb, line 60 def match?(header, pattern) header&.match(pattern) end
Source
# File lib/doorkeeper/oauth/token.rb, line 47 def token_from_basic_header(header, pattern) encoded_header = token_from_header(header, pattern) decode_basic_credentials_token(encoded_header) end
Source
# File lib/doorkeeper/oauth/token.rb, line 56 def token_from_header(header, pattern) header.gsub(pattern, "") end