Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Login.gov Redirect #143

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cf/manifest.prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
applications:
- name: srt-server-prod
- name: srt-api-prod
memory: 1024M
disk_quota: 2048M
# health-check-type: process # don't re-enable....move to port 8080 if you have problems
Expand Down
2 changes: 1 addition & 1 deletion cf/manifest.staging.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
applications:
- name: srt-server-staging
- name: srt-api-staging
memory: 1024M
disk_quota: 2048M
# health-check-type: process # don't re-enable....move to port 8080 if you have problems
Expand Down
13 changes: 13 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const logger = require('./config/winston')
const {cleanAwardNotices} = require('./cron/noticeAwardCleanup')
const {CronJob} = require('cron')
const pg = require('pg');
const querystring = require('querystring');

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

Expand Down Expand Up @@ -223,6 +224,18 @@ module.exports = {
app.get("/api/login", (req, res) => {
res.redirect(login_gov_auth_url);
});
app.get("/api/logout", (req, res) => {

const logoutEndPoint = config['login_gov_oidc']['logout_endpoint']

const params = {
client_id: config['login_gov_oidc']['client_id'],
post_logout_redirect_uri: config['srtClientUrl'] + '/auth',
}

res.redirect(logoutEndPoint + '?' + querystring.stringify(params))

});
// Login.gov Failure to Proof URL:
// For users who are unable to complete identity proofing and returning to the app
app.get("odic/failure", (req, res) => {
Expand Down
11 changes: 8 additions & 3 deletions server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ module.exports = {
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
"redirect_uri": "http://localhost:3000/odic/callback"
"redirect_uri": "http://localhost:3000/odic/callback",
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",

},
"maxCas" : {
"cas_url" : "https://login.test.max.gov/cas/",
Expand Down Expand Up @@ -431,7 +433,8 @@ module.exports = {
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
"redirect_uri": "http://srt-server-dev.app.cloud.gov/odic/callback"
"redirect_uri": "http://srt-server-dev.app.cloud.gov/odic/callback",
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
},
"maxCas" : {
"cas_url" : "https://login.test.max.gov/cas/",
Expand Down Expand Up @@ -472,7 +475,8 @@ module.exports = {
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
"redirect_uri": "http://srt-server-staging.app.cloud.gov/odic/callback"
"redirect_uri": "http://srt-server-staging.app.cloud.gov/odic/callback",
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
},
"maxCas" : {
"cas_url" : "https://login.test.max.gov/cas/",
Expand Down Expand Up @@ -551,6 +555,7 @@ module.exports = {
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"token_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/token",
"user_endpoint": "https://idp.int.identitysandbox.gov/api/openid_connect/userinfo",
"logout_endpoint": "https://idp.int.identitysandbox.gov/openid_connect/logout",
},
"maxCas" : {
"cas_url" : "https://login.max.gov/cas/",
Expand Down
7 changes: 4 additions & 3 deletions server/routes/auth.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,13 @@ module.exports = {
userRole: srt_userinfo.userRole,
firstName: srt_userinfo.firstName || userInfo.given_name,
lastName: srt_userinfo.lastName || userInfo.family_name,
loginMethod: "login.gov",
}
let location = `${config['srtClientUrl']}/auth?info=${jsonToURI(uri_components)}`

//console.log("Redirecting to: ", location)

return res.status(302)
.set('Location', location)
.send(`<html lang="en"><body>Preparing login</body></html>`)
return res.redirect(302, location);
})
});

Expand Down