Skip to content

Commit

Permalink
HWPV-128 migrate to hmpps manage users api (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
pk2453 committed Jan 15, 2024
1 parent 347e214 commit 5752095
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ module.exports = function (app) {
function (accessToken, refreshToken, params, profile, done) {
// Call API to get details on user
const options = {
url: `${config.TOKEN_HOST}${config.USER_PATH_PREFIX}${config.USER_DETAILS_PATH}`,
url: `${config.MANAGE_USERS_HOST}${config.MANAGE_USER_PATH_PREFIX}${config.MANAGE_USER_DETAILS_PATH}`,
headers: `Authorization: Bearer ${accessToken}`
}
axios(options)
.then(function (response) {
if (response.status === 200) {
let roles = []
const userDetails = response.data
options.url = `${config.TOKEN_HOST}${config.USER_PATH_PREFIX}/${userDetails.username}${config.USER_EMAIL_PATH}`
options.url = `${config.MANAGE_USERS_HOST}${config.MANAGE_USER_PATH_PREFIX}/${userDetails.username}${config.MANAGE_USER_EMAIL_PATH}`

axios(options)
.then(function (response) {
if (response.status === 200) {
const userEmail = response.data
options.url = `${config.TOKEN_HOST}${config.USER_PATH_PREFIX}${config.USER_ROLES_PATH}`
options.url = `${config.MANAGE_USERS_HOST}${config.MANAGE_USER_PATH_PREFIX}${config.MANAGE_USER_ROLES_PATH}`

axios(options)
.then(function (response) {
Expand Down
9 changes: 5 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ module.exports = {
CLIENT_ID: process.env.APVS_MOJ_SSO_CLIENT_ID,
CLIENT_SECRET: process.env.APVS_MOJ_SSO_CLIENT_SECRET,
TOKEN_HOST: process.env.APVS_MOJ_SSO_TOKEN_HOST,
MANAGE_USERS_HOST: process.env.MANAGE_USERS_API_URL,
TOKEN_PATH: process.env.APVS_MOJ_SSO_TOKEN_PATH,
AUTHORIZE_PATH: process.env.APVS_MOJ_SSO_AUTHORIZE_PATH,
REDIRECT_URI: process.env.APVS_MOJ_SSO_REDIRECT_URI,
USER_PATH_PREFIX: process.env.APVS_MOJ_SSO_USER_PATH_PREFIX,
USER_DETAILS_PATH: process.env.APVS_MOJ_SSO_USER_DETAILS_PATH,
USER_EMAIL_PATH: process.env.APVS_MOJ_SSO_USER_EMAIL_PATH,
USER_ROLES_PATH: process.env.APVS_MOJ_SSO_USER_ROLES_PATH,
MANAGE_USER_PATH_PREFIX: process.env.MANAGE_USERS_API_PATH_PREFIX,
MANAGE_USER_DETAILS_PATH: process.env.MANAGE_USERS_API_USER_DETAILS_PATH,
MANAGE_USER_EMAIL_PATH: process.env.MANAGE_USERS_API_USER_EMAIL_PATH,
MANAGE_USER_ROLES_PATH: process.env.MANAGE_USERS_API_USER_ROLES_PATH,
LOGOUT_PATH: process.env.APVS_MOJ_SSO_LOGOUT_PATH,
TEST_SSO_EMAIL: process.env.APVS_MOJ_SSO_TEST_SSO_EMAIL,
TEST_SSO_PASSWORD: process.env.APVS_MOJ_SSO_TEST_SSO_PASSWORD,
Expand Down
8 changes: 4 additions & 4 deletions helm_deploy/help-with-prison-visits-internal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ generic-service:
APVS_MOJ_SSO_AUTHENTICATION_ENABLED: 'true'
APVS_MOJ_SSO_TOKEN_PATH: '/oauth/token'
APVS_MOJ_SSO_AUTHORIZE_PATH: '/oauth/authorize'
APVS_MOJ_SSO_USER_PATH_PREFIX: /api/user
APVS_MOJ_SSO_USER_DETAILS_PATH: '/me'
APVS_MOJ_SSO_USER_EMAIL_PATH: '/email'
APVS_MOJ_SSO_USER_ROLES_PATH: '/me/roles'
MANAGE_USERS_API_PATH_PREFIX: /users
MANAGE_USERS_API_USER_DETAILS_PATH: '/me'
MANAGE_USERS_API_USER_EMAIL_PATH: '/email'
MANAGE_USERS_API_USER_ROLES_PATH: '/me/roles'
APVS_MOJ_SSO_LOGOUT_PATH: '/logout'
APVS_INT_SECURE_COOKIE: 'true'
NODE_ENV: 'production'
Expand Down
1 change: 1 addition & 0 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ generic-service:
env:
APVS_MOJ_SSO_REDIRECT_URI: 'https://manage.hwpv-dev.hmpps.service.justice.gov.uk/login/callback'
APVS_MOJ_SSO_TOKEN_HOST: 'https://sign-in-dev.hmpps.service.justice.gov.uk/auth'
MANAGE_USERS_API_URL: 'https://manage-users-api-dev.hmpps.service.justice.gov.uk'
APVS_EXTERNAL_SERVICE_URL: 'https://help-with-prison-visits-dev.hmpps.service.justice.gov.uk'
HWPV_COOKIE_DOMAIN: "manage.hwpv-dev.hmpps.service.justice.gov.uk"
HWPV_POST_LOGOUT_URL: "https://manage.hwpv-dev.hmpps.service.justice.gov.uk/"
Expand Down
1 change: 1 addition & 0 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ generic-service:
env:
APVS_MOJ_SSO_REDIRECT_URI: 'https://manage.hwpv-preprod.hmpps.service.justice.gov.uk/login/callback'
APVS_MOJ_SSO_TOKEN_HOST: 'https://sign-in-preprod.hmpps.service.justice.gov.uk/auth'
MANAGE_USERS_API_URL: 'https://manage-users-api-preprod.hmpps.service.justice.gov.uk'
APVS_EXTERNAL_SERVICE_URL: 'https://help-with-prison-visits-preprod.hmpps.service.justice.gov.uk'
HWPV_COOKIE_DOMAIN: "manage.hwpv-preprod.hmpps.service.justice.gov.uk"
HWPV_POST_LOGOUT_URL: "https://manage.hwpv-preprod.hmpps.service.justice.gov.uk/"
Expand Down
1 change: 1 addition & 0 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ generic-service:
env:
APVS_MOJ_SSO_REDIRECT_URI: 'https://caseworker.help-with-prison-visits.service.gov.uk/login/callback'
APVS_MOJ_SSO_TOKEN_HOST: 'https://sign-in.hmpps.service.justice.gov.uk/auth'
MANAGE_USERS_API_URL: 'https://manage-users-api.hmpps.service.justice.gov.uk'
APVS_EXTERNAL_SERVICE_URL: 'https://help-with-prison-visits.service.gov.uk'
HWPV_COOKIE_DOMAIN: "caseworker.help-with-prison-visits.service.gov.uk"
HWPV_POST_LOGOUT_URL: "https://caseworker.help-with-prison-visits.service.gov.uk/"
Expand Down

0 comments on commit 5752095

Please sign in to comment.