Module: Gruf::Authentication
- Defined in:
- lib/gruf/authentication.rb,
lib/gruf/authentication/base.rb,
lib/gruf/authentication/none.rb,
lib/gruf/authentication/basic.rb,
lib/gruf/authentication/strategies.rb
Overview
Handles authentication for gruf services
Defined Under Namespace
Classes: Base, Basic, None, Strategies, UnauthorizedError
Class Method Summary collapse
-
.verify(call) ⇒ Boolean
Verify a given gruf request.
Class Method Details
.verify(call) ⇒ Boolean
Verify a given gruf request
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gruf/authentication.rb', line 39 def self.verify(call) credentials = call && call.respond_to?(:metadata) ? call.[Gruf.] : nil if Gruf::Authentication::Strategies.any? verified = false Gruf::Authentication::Strategies.each do |_label, klass| begin # if a strategy passes, we've successfully authenticated and can proceed if klass.verify(call, credentials) verified = true break end rescue => e Gruf.logger.error "#{e.} - #{e.backtrace[0..4].join("\n")}" # NOOP, we don't want to fail other strategies because of a bad neighbor # or if a strategy throws an exception because of a failed auth # we should just proceed to the next strategy end end verified else # we're not using any strategies, so no auth true end end |