Class: Net::SASL::PlainAuthenticator
- Inherits:
-
Authenticator
- Object
- Authenticator
- Net::SASL::PlainAuthenticator
- Defined in:
- lib/net/sasl/plain_authenticator.rb
Overview
Authenticator for the “PLAIN
” SASL mechanism, specified in RFC4616. The authentication credentials are transmitted in cleartext, so this mechanism should only be used over an encrypted link.
Instance Attribute Summary collapse
-
#authzid ⇒ Object
readonly
Returns the value of attribute authzid.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username, password, authzid = nil, **_options) ⇒ PlainAuthenticator
constructor
username
is the authentication identity, the identity whosepassword
is used. -
#process(data) ⇒ Object
returns the SASL response for
PLAIN
. -
#supports_initial_response? ⇒ Boolean
PLAIN
does support SASL-IR.
Constructor Details
#initialize(username, password, authzid = nil, **_options) ⇒ PlainAuthenticator
username
is the authentication identity, the identity whose password
is used. username
is referred to as authcid
by RFC4616.
authzid
is the authorization identity (identity to act as). It can usually be left blank. When authzid
is left blank (nil or empty string) the server will derive an identity from the credentials and use that as the authorization identity.
This should generally be instantiated via Net::SASL.authenticator.
31 32 33 34 35 36 37 |
# File 'lib/net/sasl/plain_authenticator.rb', line 31 def initialize(username, password, authzid = nil, **) raise ArgumentError, "username contains NULL" if username&.include?(NULL) raise ArgumentError, "password contains NULL" if password&.include?(NULL) raise ArgumentError, "authzid contains NULL" if authzid&.include?(NULL) super @done = false end |
Instance Attribute Details
#authzid ⇒ Object (readonly)
Returns the value of attribute authzid.
16 17 18 |
# File 'lib/net/sasl/plain_authenticator.rb', line 16 def authzid @authzid end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
16 17 18 |
# File 'lib/net/sasl/plain_authenticator.rb', line 16 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
16 17 18 |
# File 'lib/net/sasl/plain_authenticator.rb', line 16 def username @username end |
Instance Method Details
#process(data) ⇒ Object
returns the SASL response for PLAIN
45 46 47 48 |
# File 'lib/net/sasl/plain_authenticator.rb', line 45 def process(data) @done = true "#{@authzid}\0#{@username}\0#{@password}" end |
#supports_initial_response? ⇒ Boolean
PLAIN
does support SASL-IR
40 41 42 |
# File 'lib/net/sasl/plain_authenticator.rb', line 40 def supports_initial_response? true end |