Skip to content

SudoSOS Back-end API / internal/controllers / AuthenticationController

Class: AuthenticationController ​

The authentication controller is responsible for verifying user authentications and handing out json web tokens.

Extends ​

Constructors ​

Constructor ​

ts
new AuthenticationController(options, tokenHandler): AuthenticationController;

Creates a new authentication controller instance.

Parameters ​

ParameterTypeDescription
optionsBaseControllerOptionsThe options passed to the base controller.
tokenHandlerTokenHandlerThe token handler for creating signed tokens.

Returns ​

AuthenticationController

Overrides ​

BaseController.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
roleManagerprotectedRoleManagerA reference to the role manager passed in the base controller options.BaseController.roleManager
specificationpublicSwaggerSpecificationA reference to the swagger specification passed in the base controller options.BaseController.specification
tokenHandlerprotectedTokenHandlerReference to the token handler of the application.-

Methods ​

createResetToken() ​

ts
createResetToken(req, res): Promise<void>;

POST /authentication/local/reset

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

204 - Creation success

Operation Id ​

resetLocal

Tags ​

authenticate - Operations of authentication controller


eanLogin() ​

ts
eanLogin(req, res): Promise<void>;

POST /authentication/ean

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Deprecated ​

Use /authentication/ean-secure instead

Operation Id ​

eanAuthentication

Tags ​

authenticate - Operations of authentication controller


getJWTPublicKey() ​

ts
getJWTPublicKey(req, res): Promise<void>;

GET /authentication/public

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - Public key

Operation Id ​

getJWTPublicKey

Tags ​

authenticate - Operations of authentication controller


getPolicy() ​

ts
getPolicy(): Policy;

Gets the policy defined by child classes. This policy includes all routes that the controller accepts, the authorization middleware, and the final handler function for every route.

Returns ​

Policy

The policy of this controller.

Overrides ​

BaseController.getPolicy


getRouter() ​

ts
getRouter(): Router;

Returns ​

Router

the router used by this controller.

Inherited from ​

BaseController.getRouter


keyLogin() ​

ts
keyLogin(req, res): Promise<void>;

POST /authentication/key

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Operation Id ​

keyAuthentication

Tags ​

authenticate - Operations of authentication controller


LDAPLogin() ​

ts
LDAPLogin(req, res): Promise<void>;

POST /authentication/LDAP

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Operation Id ​

ldapAuthentication

Tags ​

authenticate - Operations of authentication controller


LocalLogin() ​

ts
LocalLogin(req, res): Promise<void>;

POST /authentication/local

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Operation Id ​

localAuthentication

Tags ​

authenticate - Operations of authentication controller


mockLogin() ​

ts
mockLogin(req, res): Promise<void>;

POST /authentication/mock

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Operation Id ​

mockAuthentication

Tags ​

authenticate - Operations of authentication controller


nfcLogin() ​

ts
nfcLogin(req, res): Promise<void>;

POST /authentication/nfc

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Deprecated ​

Use /authentication/nfc-secure instead

Operation Id ​

nfcAuthentication

Tags ​

authenticate - Operations of authentication controller


PINLogin() ​

ts
PINLogin(req, res): Promise<void>;

POST /authentication/pin

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

200 - The created json web token.

Deprecated ​

Use /authentication/pin-secure instead

Operation Id ​

pinAuthentication

Tags ​

authenticate - Operations of authentication controller


resetLocalUsingToken() ​

ts
resetLocalUsingToken(req, res): Promise<void>;

PUT /authentication/local

Parameters ​

ParameterType
reqRequest
resResponse

Returns ​

Promise<void>

204 - Successfully reset

Operation Id ​

resetLocalWithToken

Tags ​

authenticate - Operations of authentication controller


canPerformMock() ​

ts
static canPerformMock(req): Promise<boolean>;

Validates that the request is authorized by the policy.

Parameters ​

ParameterTypeDescription
reqRequestThe incoming request.

Returns ​

Promise<boolean>


LDAPLoginConstructor() ​

ts
static LDAPLoginConstructor(
   roleManager, 
   tokenHandler, 
onNewUser): (req, res) => Promise<void>;

Constructor for the LDAP function to make it easily adaptable.

Parameters ​

ParameterType
roleManagerRoleManager
tokenHandlerTokenHandler
onNewUser(ADUser) => Promise<User>

Returns ​

ts
(req, res): Promise<void>;
Parameters ​
ParameterType
reqRequest
resResponse
Returns ​

Promise<void>


PINLoginConstructor() ​

ts
static PINLoginConstructor(
   roleManager, 
   tokenHandler, 
   pin, 
   userId, 
posId?): (req, res) => Promise<void>;

Construct a login function for PIN. This was done such that it is easily adaptable.

Parameters ​

ParameterTypeDescription
roleManagerRoleManager-
tokenHandlerTokenHandler-
pinstringProvided PIN code
userIdnumberProvided User
posId?numberOptional POS identifier (only used by secure endpoints)

Returns ​

ts
(req, res): Promise<void>;
Parameters ​
ParameterType
reqRequest
resResponse
Returns ​

Promise<void>