Class Mongo::Auth::User
In: lib/mongo/auth/user/view.rb
lib/mongo/auth/user.rb
Parent: Object

Represents a user in MongoDB.

@since 2.0.0

Methods

Included Modules

Loggable

Classes and Modules

Class Mongo::Auth::User::View

Attributes

auth_mech_properties  [R]  @return [ Hash ] The authentication mechanism properties.
auth_source  [R]  @return [ String ] The authorization source, either a database or
  external name.
client_key  [R]  The client key for the user.

@return [ String ] The client key for the user.

database  [R]  @return [ String ] The database the user is created in.
mechanism  [R]  @return [ Symbol ] The authorization mechanism.
name  [R]  @return [ String ] The username.
password  [R]  @return [ String ] The cleartext password.
roles  [R]  @return [ Array<String> ] roles The user roles.

Public Class methods

Create the new user.

@example Create a new user.

  Mongo::Auth::User.new(options)

@param [ Hash ] options The options to create the user from.

@option options [ String ] :auth_source The authorization database or

  external source.

@option options [ String ] :database The database the user is

  authorized for.

@option options [ String ] :user The user name. @option options [ String ] :password The user‘s password. @option options [ Symbol ] :auth_mech The authorization mechanism. @option options [ Array<String>, Array<Hash> ] roles The user roles. @option options [ String ] :client_key The user‘s client key cached from a previous

  authentication on the same connection.

@since 2.0.0

Public Instance methods

Determine if this user is equal to another.

@example Check user equality.

  user == other

@param [ Object ] other The object to compare against.

@return [ true, false ] If the objects are equal.

@since 2.0.0

Get an authentication key for the user based on a nonce from the server.

@example Get the authentication key.

  user.auth_key(nonce)

@param [ String ] nonce The response from the server.

@return [ String ] The authentication key.

@since 2.0.0

Get the UTF-8 encoded name with escaped special characters for use with SCRAM authorization.

@example Get the encoded name.

  user.encoded_name

@return [ String ] The encoded user name.

@since 2.0.0

Get the hash key for the user.

@example Get the hash key.

  user.hash

@return [ String ] The user hash key.

@since 2.0.0

Get the user‘s hashed password for SCRAM-SHA-1.

@example Get the user‘s hashed password.

  user.hashed_password

@return [ String ] The hashed password.

@since 2.0.0

Loggable requires an options attribute. We don‘t have any options hence provide this as a stub.

@api private

Get the user‘s stringprepped password for SCRAM-SHA-256.

@api private

Get the specification for the user, used in creation.

@example Get the user‘s specification.

  user.spec

@return [ Hash ] The user spec.

@since 2.0.0

[Validate]