ldapts
Advanced tools
Comparing version 2.9.1 to 2.10.0
@@ -0,1 +1,4 @@ | ||
### 2.10.0 | ||
* Add support for PLAIN and EXTERNAL SASL authentication to bind request | ||
### 2.9.1 | ||
@@ -2,0 +5,0 @@ * Simplify control import directives |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import type { Filter } from './filters/Filter'; | ||
import type { Entry } from './messages'; | ||
import type { Entry, SaslMechanism } from './messages'; | ||
export interface ClientOptions { | ||
@@ -104,8 +104,8 @@ /** | ||
/** | ||
* Performs a simple authentication against the server. | ||
* @param {string|DN} dn | ||
* Performs a simple or sasl authentication against the server. | ||
* @param {string|DN|SaslMechanism} dnOrSaslMechanism | ||
* @param {string} [password] | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
bind(dn: string | DN, password?: string, controls?: Control | Control[]): Promise<void>; | ||
bind(dnOrSaslMechanism: string | DN | SaslMechanism, password?: string, controls?: Control | Control[]): Promise<void>; | ||
/** | ||
@@ -112,0 +112,0 @@ * Used to create a new entry in the directory |
@@ -126,8 +126,8 @@ "use strict"; | ||
/** | ||
* Performs a simple authentication against the server. | ||
* @param {string|DN} dn | ||
* Performs a simple or sasl authentication against the server. | ||
* @param {string|DN|SaslMechanism} dnOrSaslMechanism | ||
* @param {string} [password] | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
async bind(dn, password, controls) { | ||
async bind(dnOrSaslMechanism, password, controls) { | ||
if (!this.connected) { | ||
@@ -139,8 +139,19 @@ await this._connect(); | ||
} | ||
const req = new messages_1.BindRequest({ | ||
messageId: this._nextMessageId(), | ||
dn: typeof dn === 'string' ? dn : dn.toString(), | ||
password, | ||
controls, | ||
}); | ||
let req; | ||
if (dnOrSaslMechanism === 'PLAIN' || dnOrSaslMechanism === 'EXTERNAL') { | ||
req = new messages_1.BindRequest({ | ||
messageId: this._nextMessageId(), | ||
mechanism: dnOrSaslMechanism, | ||
password, | ||
controls, | ||
}); | ||
} | ||
else { | ||
req = new messages_1.BindRequest({ | ||
messageId: this._nextMessageId(), | ||
dn: typeof dnOrSaslMechanism === 'string' ? dnOrSaslMechanism : dnOrSaslMechanism.toString(), | ||
password, | ||
controls, | ||
}); | ||
} | ||
const result = await this._send(req); | ||
@@ -147,0 +158,0 @@ if (result.status !== MessageResponseStatus_1.MessageResponseStatus.Success) { |
@@ -29,2 +29,3 @@ export * from './AdminLimitExceededError'; | ||
export * from './ResultsTooLargeError'; | ||
export * from './SaslBindInProgressError'; | ||
export * from './SizeLimitExceededError'; | ||
@@ -31,0 +32,0 @@ export * from './StrongAuthRequiredError'; |
@@ -41,2 +41,3 @@ "use strict"; | ||
__exportStar(require("./ResultsTooLargeError"), exports); | ||
__exportStar(require("./SaslBindInProgressError"), exports); | ||
__exportStar(require("./SizeLimitExceededError"), exports); | ||
@@ -43,0 +44,0 @@ __exportStar(require("./StrongAuthRequiredError"), exports); |
@@ -5,5 +5,7 @@ import type { BerReader, BerWriter } from 'asn1'; | ||
import { Message } from './Message'; | ||
export declare type SaslMechanism = 'PLAIN' | 'EXTERNAL'; | ||
export interface BindRequestMessageOptions extends MessageOptions { | ||
dn?: string; | ||
password?: string; | ||
mechanism?: SaslMechanism; | ||
} | ||
@@ -14,2 +16,3 @@ export declare class BindRequest extends Message { | ||
password: string; | ||
mechanism: SaslMechanism | undefined; | ||
constructor(options: BindRequestMessageOptions); | ||
@@ -16,0 +19,0 @@ writeMessage(writer: BerWriter): void; |
@@ -13,2 +13,3 @@ "use strict"; | ||
this.password = options.password || ''; | ||
this.mechanism = options.mechanism; | ||
} | ||
@@ -18,3 +19,15 @@ writeMessage(writer) { | ||
writer.writeString(this.dn); | ||
writer.writeString(this.password, asn1_1.Ber.Context); | ||
if (this.mechanism) { | ||
// SASL authentication | ||
writer.startSequence(ProtocolOperation_1.ProtocolOperation.LDAP_REQ_BIND_SASL); | ||
writer.writeString(this.mechanism); | ||
if (this.password) { | ||
writer.writeString(this.password); | ||
} | ||
writer.endSequence(); | ||
} | ||
else { | ||
// Simple authentication | ||
writer.writeString(this.password, asn1_1.Ber.Context); // 128 | ||
} | ||
} | ||
@@ -21,0 +34,0 @@ parseMessage(reader) { |
{ | ||
"name": "ldapts", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"description": "LDAP client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,3 @@ export declare enum ProtocolOperation { | ||
LDAP_REQ_BIND = 96, | ||
LDAP_REQ_BIND_SASL = 163, | ||
LDAP_REQ_UNBIND = 66, | ||
@@ -8,0 +9,0 @@ LDAP_REQ_SEARCH = 99, |
@@ -12,2 +12,3 @@ "use strict"; | ||
ProtocolOperation[ProtocolOperation["LDAP_REQ_BIND"] = 96] = "LDAP_REQ_BIND"; | ||
ProtocolOperation[ProtocolOperation["LDAP_REQ_BIND_SASL"] = 163] = "LDAP_REQ_BIND_SASL"; | ||
ProtocolOperation[ProtocolOperation["LDAP_REQ_UNBIND"] = 66] = "LDAP_REQ_UNBIND"; | ||
@@ -14,0 +15,0 @@ ProtocolOperation[ProtocolOperation["LDAP_REQ_SEARCH"] = 99] = "LDAP_REQ_SEARCH"; |
@@ -94,10 +94,19 @@ LDAPts | ||
|---------|-------------- | ||
|`dn` (string)|The name (DN) of the directory object that the client wishes to bind as | ||
|`dnOrSaslMechanism` (string)|The name (DN) of the directory object that the client wishes to bind as or the SASL mechanism (PLAIN, EXTERNAL) | ||
|`password` (string)|Password for the target bind DN | ||
|`[controls]` (Control|Control[])|Optional `Control` object or array of `Control` objects | ||
Example: | ||
Simple Example: | ||
await client.bind('cn=root', 'secret'); | ||
SASL Example: | ||
// No credentials | ||
await client.bind("EXTERNAL"); | ||
// With credentials | ||
const credentials = '...foo...'; | ||
await client.bind("EXTERNAL", credentials); | ||
## startTLS | ||
@@ -104,0 +113,0 @@ `startTLS(options, [controls])` |
@@ -27,2 +27,4 @@ "use strict"; | ||
return new resultCodeErrors_1.ConfidentialityRequiredError(message); | ||
case 14: | ||
return new resultCodeErrors_1.SaslBindInProgressError(message); | ||
case 16: | ||
@@ -29,0 +31,0 @@ return new resultCodeErrors_1.NoSuchAttributeError(message); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
338620
295
5152
480