Skip to content

Commit 263c7f9

Browse files
authored
Merge pull request #143 from BuckinghamAJ/dev
Fixing Login.gov Redirect
2 parents 92430ce + fb8a790 commit 263c7f9

5 files changed

Lines changed: 27 additions & 8 deletions

File tree

cf/manifest.prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
applications:
3-
- name: srt-server-prod
3+
- name: srt-api-prod
44
memory: 1024M
55
disk_quota: 2048M
66
# health-check-type: process # don't re-enable....move to port 8080 if you have problems

cf/manifest.staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
applications:
3-
- name: srt-server-staging
3+
- name: srt-api-staging
44
memory: 1024M
55
disk_quota: 2048M
66
# health-check-type: process # don't re-enable....move to port 8080 if you have problems

server/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const logger = require('./config/winston')
1717
const {cleanAwardNotices} = require('./cron/noticeAwardCleanup')
1818
const {CronJob} = require('cron')
1919
const pg = require('pg');
20+
const querystring = require('querystring');
2021

2122
const { Issuer, Strategy, generators } = require('openid-client');
2223

@@ -223,6 +224,18 @@ module.exports = {
223224
app.get("/api/login", (req, res) => {
224225
res.redirect(login_gov_auth_url);
225226
});
227+
app.get("/api/logout", (req, res) => {
228+
229+
const logoutEndPoint = config['login_gov_oidc']['logout_endpoint']
230+
231+
const params = {
232+
client_id: config['login_gov_oidc']['client_id'],
233+
post_logout_redirect_uri: config['srtClientUrl'] + '/auth',
234+
}
235+
236+
res.redirect(logoutEndPoint + '?' + querystring.stringify(params))
237+
238+
});
226239
// Login.gov Failure to Proof URL:
227240
// For users who are unable to complete identity proofing and returning to the app
228241
app.get("odic/failure", (req, res) => {

server/config/config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ module.exports = {
351351
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
352352
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
353353
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
354-
"redirect_uri": "http://localhost:3000/odic/callback"
354+
"redirect_uri": "http://localhost:3000/odic/callback",
355+
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
356+
355357
},
356358
"maxCas" : {
357359
"cas_url" : "https://login.test.max.gov/cas/",
@@ -431,7 +433,8 @@ module.exports = {
431433
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
432434
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
433435
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
434-
"redirect_uri": "http://srt-server-dev.app.cloud.gov/odic/callback"
436+
"redirect_uri": "http://srt-server-dev.app.cloud.gov/odic/callback",
437+
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
435438
},
436439
"maxCas" : {
437440
"cas_url" : "https://login.test.max.gov/cas/",
@@ -472,7 +475,8 @@ module.exports = {
472475
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
473476
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
474477
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
475-
"redirect_uri": "http://srt-server-staging.app.cloud.gov/odic/callback"
478+
"redirect_uri": "http://srt-server-staging.app.cloud.gov/odic/callback",
479+
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
476480
},
477481
"maxCas" : {
478482
"cas_url" : "https://login.test.max.gov/cas/",
@@ -551,6 +555,7 @@ module.exports = {
551555
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
552556
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
553557
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
558+
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
554559
},
555560
"maxCas" : {
556561
"cas_url" : "https://login.max.gov/cas/",

server/routes/auth.routes.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,13 @@ module.exports = {
552552
userRole: srt_userinfo.userRole,
553553
firstName: srt_userinfo.firstName || userInfo.given_name,
554554
lastName: srt_userinfo.lastName || userInfo.family_name,
555+
loginMethod: "login.gov",
555556
}
556557
let location = `${config['srtClientUrl']}/auth?info=${jsonToURI(uri_components)}`
558+
559+
//console.log("Redirecting to: ", location)
557560

558-
return res.status(302)
559-
.set('Location', location)
560-
.send(`<html lang="en"><body>Preparing login</body></html>`)
561+
return res.redirect(302, location);
561562
})
562563
});
563564

0 commit comments

Comments
 (0)