The username.
The password.
Optional
onValidationFailed: Nilable<BasicAuthValidationFailedHandler>The custom handler, that is invoked, if validation fails.
The name middleware.
import createServer, { basicAuth, BasicAuthCredentials, IHttpRequest, IHttpResponse } from '@egomobile/http-server'
const app = createServer()
const usersAndPasswords: BasicAuthCredentials = {
'bill': 'G@tez1234$',
'marcel': 'fooPassword',
'tanja': 'barPasswd1234'
}
app.get('/', basicAuth(usersAndPasswords), async (response: IHttpRequest, response: IHttpResponse) => {
// your code, if credentials are valid
})
Optional
onValidationFailed: Nilable<BasicAuthValidationFailedHandler>Optional
onValidationFailed: Nilable<BasicAuthValidationFailedHandler>Generated using TypeDoc
Creates a new middleware, that checks, if Authorization header is valid or not.