Skip to main content
Version: Next

Interface: Auth<T>

pluginUtils.Auth

The base plugin class, set of utilities for developing plugins.

Type parameters

Name
T

Hierarchy

Properties

config

Readonly config: unknown

Inherited from

Plugin.config

Defined in

plugin-utils.ts:36


options

Readonly options: PluginOptions

Inherited from

Plugin.options

Defined in

plugin-utils.ts:37


version

Readonly version: number

Inherited from

Plugin.version

Defined in

plugin-utils.ts:35

Methods

adduser

Optional adduser(user, password, cb): void

Handles the authenticated method.

 class Auth {
public adduser(user: string, password: string, done: AuthCallback): void {
if (!password) {
return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));
}
// return boolean
return done(null, true);
}

Parameters

NameType
userstring
passwordstring
cbAuthUserCallback

Returns

void

Defined in

plugin-utils.ts:144


allow_access

Optional allow_access(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgT & PackageAccess
cbAccessCallback

Returns

void

Defined in

plugin-utils.ts:153

Optional allow_access(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgAllowAccess & PackageAccess
cbAccessCallback

Returns

void

Defined in

plugin-utils.ts:154


allow_publish

Optional allow_publish(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgT & PackageAccess
cbAuthAccessCallback

Returns

void

Defined in

plugin-utils.ts:151

Optional allow_publish(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgAllowAccess & PackageAccess
cbAuthAccessCallback

Returns

void

Defined in

plugin-utils.ts:152


allow_unpublish

Optional allow_unpublish(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgT & PackageAccess
cbAuthAccessCallback

Returns

void

Defined in

plugin-utils.ts:155

Optional allow_unpublish(user, pkg, cb): void

Parameters

NameType
userRemoteUser
pkgAllowAccess & PackageAccess
cbAuthAccessCallback

Returns

void

Defined in

plugin-utils.ts:156


apiJWTmiddleware

Optional apiJWTmiddleware(helpers): RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Parameters

NameType
helpersany

Returns

RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Defined in

plugin-utils.ts:161


authenticate

authenticate(user, password, cb): void

Handles the authenticated method.

 class Auth {
public authenticate(user: string, password: string, done: AuthCallback): void {
if (!password) {
return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));
}
// always return an array of users
return done(null, [user]);
}

Parameters

NameType
userstring
passwordstring
cbAuthCallback

Returns

void

Defined in

plugin-utils.ts:130


changePassword

Optional changePassword(user, password, newPassword, cb): void

Parameters

NameType
userstring
passwordstring
newPasswordstring
cbAuthChangePasswordCallback

Returns

void

Defined in

plugin-utils.ts:145


getVersion

getVersion(): number

Returns

number

Inherited from

Plugin.getVersion

Defined in

plugin-utils.ts:44