Interface: Auth<T>
pluginUtils.Auth
The base plugin class, set of utilities for developing plugins.
Type parameters
Name |
---|
T |
Hierarchy
Plugin
<T
>↳
Auth
Properties
config
• Readonly
config: unknown
Inherited from
Defined in
options
• Readonly
options: PluginOptions
Inherited from
Defined in
version
• Readonly
version: number
Inherited from
Defined in
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
Name | Type |
---|---|
user | string |
password | string |
cb | AuthUserCallback |
Returns
void
Defined in
allow_access
▸ Optional
allow_access(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | T & PackageAccess |
cb | AccessCallback |
Returns
void
Defined in
▸ Optional
allow_access(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | AllowAccess & PackageAccess |
cb | AccessCallback |
Returns
void
Defined in
allow_publish
▸ Optional
allow_publish(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | T & PackageAccess |
cb | AuthAccessCallback |
Returns
void
Defined in
▸ Optional
allow_publish(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | AllowAccess & PackageAccess |
cb | AuthAccessCallback |
Returns
void
Defined in
allow_unpublish
▸ Optional
allow_unpublish(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | T & PackageAccess |
cb | AuthAccessCallback |
Returns
void
Defined in
▸ Optional
allow_unpublish(user
, pkg
, cb
): void
Parameters
Name | Type |
---|---|
user | RemoteUser |
pkg | AllowAccess & PackageAccess |
cb | AuthAccessCallback |
Returns
void
Defined in
apiJWTmiddleware
▸ Optional
apiJWTmiddleware(helpers
): RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record
<string
, any
>>
Parameters
Name | Type |
---|---|
helpers | any |
Returns
RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record
<string
, any
>>
Defined in
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
Name | Type |
---|---|
user | string |
password | string |
cb | AuthCallback |
Returns
void
Defined in
changePassword
▸ Optional
changePassword(user
, password
, newPassword
, cb
): void
Parameters
Name | Type |
---|---|
user | string |
password | string |
newPassword | string |
cb | AuthChangePasswordCallback |
Returns
void
Defined in
getVersion
▸ getVersion(): number
Returns
number