@ministryofjustice/hmpps-prisoner-auth
v0.0.6
Published
Middleware for providing authentication against Launchpad Auth
Downloads
510
Maintainers
Keywords
Readme
Prisoner Auth
Installation
Quick installation
The following steps will give an opinionated out of the box setup for applications where a launchpad user will be the main user in the system.
- Add the package
@ministryofjustice/hmpps-prisoner-authto yourpackage.json
npm add --save @ministryofjustice/hmpps-prisoner-auth
npm i- Copy the contents of src/misc/install.diff to your local folder
curl https://raw.githubusercontent.com/ministryofjustice/hmpps-prisoner-facing-typescript-lib/refs/heads/main/packages/prisoner-auth/src/misc/install.diff > install.diff- Apply the diff to carry out all the required changes
git apply install.diffMake sure to look through the applied changes and remove the diff file before committing.
Fill in the configuration options in
server/middleware/setUpPrisonerAuth.ts:
See PrisonerAuthOptions for full documentation on the avaialble options
Manual installation
NOTE: see install.diff for an authorititive list of changes to be made.
- Add the package
@ministryofjustice/hmpps-prisoner-authto yourpackage.json
npm add --save @ministryofjustice/hmpps-prisoner-auth
npm i- Modify
interfaces/hmppsUser.tsto make the following additions:
# add prisoner-auth to the AuthSource type
export type AuthSource = 'nomis' | 'delius' | 'external' | 'azuread' | 'prisoner-auth'
# add LaunchpadUser to the HmppsUser type
export type HmppsUser = PrisonUser | ProbationUser | ExternalUser | AzureADUser | LaunchpadUserThese changes will help smooth over alot of assumptions made in the typescript template about the type of fields the user will have.
- Add
server/middleware/setUpPrisonerAuth.tsmiddlware:
curl https://raw.githubusercontent.com/ministryofjustice/hmpps-prisoner-facing-typescript-lib/refs/heads/main/packages/prisoner-auth/src/misc/setUpPrisonerAuth.ts.example > server/middleware/setUpPrisonerAuth.tsMake sure to fill in the appropriate values.
See PrisonerAuthOptions for full documentation on the avaialble options
- Modify
server/app.ts:
- ADD
setUpPrisonerAuth()to enable the middlware. - REMOVE reference to
authorisationMiddleware()- this checks the usersROLE_which a launchpad user will not have. - REMOVE reference to
setUpCurrentUser()- this sets up theres.locals.userfields which a launchpad will have already (name,displayNameetc).
