Module: Mongo::Auth

Extended by:
Auth
Included in:
Auth
Defined in:
lib/mongo/auth.rb,
lib/mongo/auth/cr.rb,
lib/mongo/auth/ldap.rb,
lib/mongo/auth/x509.rb,
lib/mongo/auth/user.rb,
lib/mongo/auth/scram.rb,
lib/mongo/auth/roles.rb,
lib/mongo/auth/user/view.rb,
lib/mongo/auth/cr/conversation.rb,
lib/mongo/auth/ldap/conversation.rb,
lib/mongo/auth/x509/conversation.rb,
lib/mongo/auth/scram/conversation.rb

Overview

This namespace contains all authentication related behaviour.

Since:

  • 2.0.0

Defined Under Namespace

Modules: Roles Classes: CR, InvalidMechanism, LDAP, SCRAM, Unauthorized, User, X509

Constant Summary

EXTERNAL =

The external database name.

Since:

  • 2.0.0

'$external'.freeze
GET_NONCE =

Constant for the nonce command.

Since:

  • 2.0.0

{ getnonce: 1 }.freeze
NONCE =

Constant for the nonce field.

Since:

  • 2.0.0

'nonce'.freeze
SOURCES =

Map the symbols parsed from the URI connection string to strategies.

Since:

  • 2.0.0

{
  mongodb_cr: CR,
  mongodb_x509: X509,
  plain: LDAP,
  scram: SCRAM
}

Instance Method Summary collapse

Instance Method Details

#get(user) ⇒ CR, ...

Get the authorization strategy for the provided auth mechanism.

Examples:

Get the strategy.

Auth.get(user)

Parameters:

Returns:

  • (CR, X509, LDAP, Kerberos)

    The auth strategy.

Raises:

Since:

  • 2.0.0



65
66
67
68
69
# File 'lib/mongo/auth.rb', line 65

def get(user)
  mechanism = user.mechanism
  raise InvalidMechanism.new(mechanism) if !SOURCES.has_key?(mechanism)
  SOURCES[mechanism].new(user)
end