Home Reference Source
public class | source

Auth

Authenticator/passport strategy wrapper abstraction.

I.e. it is the parent class of all auth classes.

Constructor Summary

Public Constructor
public

constructor(method: string, options: object)

Member Summary

Public Members
public

Additional settings given to passport.authenticate.

public

Custom fields

public

Default error message to return instead of actual errors (security).

public

Default roles new registered users should assume.

public

This is a standard descriptor of this authentication mechanism that is publicly shared.

public

method: *

Authentication method name.

public

users: CachedCollection

Users collection.

Method Summary

Public Methods
public

async createProfileFromCredential(id: *, extra: {}): *

helper method that creates a profile object from a credential address

public

createUserFromProfile(profile: Profile): User

Helper method that creates an User object from a Profile

public

findUser(value: string): User | false

Helper method that finds an user based on a credential.

public

generateId(): *

public

handleUserLoginByProfile(username: string, profile: Profile, done: Function, req: Request)

Helper method for SSO type logins.

public abstract

install(app: ExpressApplication, prefix: string, passport: Passport)

Must be overridden to provide implementation of said authentication method.

public

loggedIn(redirect: boolean): ExpressMiddleware

Helper method that produces a middleware to handle successful logged in case.

Public Constructors

public constructor(method: string, options: object) source

Params:

NameTypeAttributeDescription
method string
options object

common options for all auth classes; see properties

Public Members

public authenticateOptions: * source

Additional settings given to passport.authenticate.

Not directly configurable.

public custom: object source

Custom fields

public defaultErrorMsg: string source

Default error message to return instead of actual errors (security).

public defaultRoles: object source

Default roles new registered users should assume.

public description: * source

This is a standard descriptor of this authentication mechanism that is publicly shared. Clients should use this to figure out how to use a login auth from outside.

Not directly configurable.

public method: * source

Authentication method name. E.g. 'email' for Email based authentication. This is used as an unique id for various things.

public users: CachedCollection source

Users collection.

Note: various things all assume that a CachedCollection is being used.

Public Methods

public async createProfileFromCredential(id: *, extra: {}): * source

helper method that creates a profile object from a credential address

Params:

NameTypeAttributeDescription
id *
extra {}
  • optional
  • default: {}

Return:

*

public createUserFromProfile(profile: Profile): User source

Helper method that creates an User object from a Profile

Params:

NameTypeAttributeDescription
profile Profile

Return:

User

public findUser(value: string): User | false source

Helper method that finds an user based on a credential.

A credential is something like an email address or a facebook user id.

This is something that uniquely identifies an account.

Params:

NameTypeAttributeDescription
value string

Return:

User | false

public generateId(): * source

Return:

*

public handleUserLoginByProfile(username: string, profile: Profile, done: Function, req: Request) source

Helper method for SSO type logins.

This method finds existing or creates new accounts basen on profile information returned from oauth partner.

Params:

NameTypeAttributeDescription
username string

unique id

profile Profile

unique id

done Function

callback to call when our work is done

req Request
  • optional

request object

public abstract install(app: ExpressApplication, prefix: string, passport: Passport) source

Must be overridden to provide implementation of said authentication method.

Params:

NameTypeAttributeDescription
app ExpressApplication

express application

prefix string

all route prefix

passport Passport

passport class

public loggedIn(redirect: boolean): ExpressMiddleware source

Helper method that produces a middleware to handle successful logged in case.

Params:

NameTypeAttributeDescription
redirect boolean
  • optional
  • default: false

redirect based login is used

Return:

ExpressMiddleware