Class: RubySMB::Gss::Provider::Multi
- Defined in:
- lib/ruby_smb/gss/provider/multi.rb
Overview
A GSS provider that offers more than one authentication mechanism to the client and routes each request to whichever of its sub-providers understands the mechanism the client selected.
SPNEGO exists so that a client and server can agree on a mechanism, but a server that only ever advertises one has nothing to negotiate. This provider advertises the mechanisms of every provider it holds, in the order they were given, so a client can pick the one it prefers.
Defined Under Namespace
Classes: Authenticator
Instance Attribute Summary collapse
-
#providers ⇒ Array<Provider::Base>
readonly
The providers this instance will route between.
Instance Method Summary collapse
- #allow_anonymous ⇒ Object
- #allow_guests ⇒ Object
-
#initialize(providers) ⇒ Multi
constructor
A new instance of Multi.
-
#mech_types ⇒ Array<OpenSSL::ASN1::ObjectId>
Every mechanism offered by every provider, in provider order, with duplicates removed so a mechanism supported by two providers is only advertised once.
- #new_authenticator(server_client) ⇒ Object
-
#provider_for(mech_type) ⇒ Provider::Base?
The first provider that handles the specified mechanism, or nil if none do.
Methods inherited from Base
Constructor Details
#initialize(providers) ⇒ Multi
Returns a new instance of Multi.
19 20 21 22 23 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 19 def initialize(providers) raise ArgumentError, 'at least one provider is required' if providers.nil? || providers.empty? @providers = providers.dup.freeze end |
Instance Attribute Details
#providers ⇒ Array<Provider::Base> (readonly)
Returns the providers this instance will route between.
26 27 28 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 26 def providers @providers end |
Instance Method Details
#allow_anonymous ⇒ Object
50 51 52 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 50 def allow_anonymous @providers.any?(&:allow_anonymous) end |
#allow_guests ⇒ Object
54 55 56 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 54 def allow_guests @providers.any?(&:allow_guests) end |
#mech_types ⇒ Array<OpenSSL::ASN1::ObjectId>
Every mechanism offered by every provider, in provider order, with duplicates removed so a mechanism supported by two providers is only advertised once.
37 38 39 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 37 def mech_types @providers.flat_map(&:mech_types).uniq(&:oid) end |
#new_authenticator(server_client) ⇒ Object
28 29 30 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 28 def new_authenticator(server_client) Authenticator.new(self, server_client) end |
#provider_for(mech_type) ⇒ Provider::Base?
The first provider that handles the specified mechanism, or nil if none do.
46 47 48 |
# File 'lib/ruby_smb/gss/provider/multi.rb', line 46 def provider_for(mech_type) @providers.find { |provider| provider.supports_mech_type?(mech_type) } end |