Class: HTTPAuth

server.HTTPAuth

Class representing a HTTP authentication method.

Password hashes for use with the users property can be generated with the passwordHash method, or with the following code on Node.js:

const crypto = require("crypto");

function md5(data)
{
    return crypto.createHash("md5").update(data).digest("hex");
}

console.log(md5("<username>:<realm>:<password>"));

new server.HTTPAuth ()

Properties:
Name Type Description
mode string

[default: "basic"] The HTTP authentication mode. One of basic|digest

realm string

[default: ""] The name of the authentication realm.

users object

[default: { }] The map of users and password hashes.

Extends

Methods

authorize (request)string

Authorizes the given HTTP request and returns a user name, or null if the request is not authorized.

Name Type Description
request HTTPRequest

The request to authorize.

Returns:
Type Description
string The user name, or null.

passwordHash (user, realm, password)string

Creates a password hash for the given user, realm, and password for use in the users table.

Name Type Description
user string

The user name.

realm string

The name of the authentication realm.

password string

The password.

Returns:
Type Description
string The password hash.

requestAuthorization (response)

Adds an authorization request to the given HTTP response.

Name Type Description
response HTTPResponse

The response object.