Class: Gruf::Authentication::Basic
- Defined in:
- lib/gruf/authentication/basic.rb
Overview
Handles basic authentication for gRPC requests
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#valid?(_call) ⇒ Boolean
True if the basic authentication was valid.
Methods inherited from Base
Methods included from Loggable
Constructor Details
This class inherits a constructor from Gruf::Authentication::Base
Instance Method Details
#valid?(_call) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gruf/authentication/basic.rb', line 29 def valid?(_call) server_credentials.any? do |cred| username = cred.fetch(:username, '').to_s password = cred.fetch(:password, '').to_s if username.empty? request_password == password else request_credentials == "#{username}:#{password}" end end end |