-
Notifications
You must be signed in to change notification settings - Fork 93
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
Vanguard integration #2254
Merged
Merged
Vanguard integration #2254
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8551706
Add vanguard login mechanism
ae55be3
Client side update
c91401f
adding node gyp dependecies for xml verification library xml crypto's…
5295b5e
Align node versions so native modules work across build and productio…
198055c
link up deployment
d754b33
Translate some fields to what other passport modules produce
3859144
Update changelog
9340680
pr feedback changes
1c041d4
Changed to fork version of passport-wsfed-saml2
AlexGilleran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:10 | ||
FROM mhart/alpine-node:8 | ||
|
||
RUN mkdir -p /usr/src/app | ||
COPY . /usr/src/app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Declarations for third-party modules without a @types package. | ||
declare module "passport-google-oauth20"; | ||
declare module "passport-arcgis"; | ||
declare module "passport-wsfed-saml2"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Strategy } from "passport-wsfed-saml2"; | ||
|
||
import * as express from "express"; | ||
import { Router } from "express"; | ||
import { Authenticator } from "passport"; | ||
|
||
import ApiClient from "@magda/typescript-common/dist/authorization-api/ApiClient"; | ||
import createOrGetUserToken from "../createOrGetUserToken"; | ||
import { redirectOnSuccess } from "./redirect"; | ||
|
||
export interface VanguardOptions { | ||
authorizationApi: ApiClient; | ||
passport: Authenticator; | ||
wsFedIdpUrl: string; | ||
wsFedRealm: string; | ||
wsFedCertificate: string; | ||
externalAuthHome: string; | ||
} | ||
|
||
const STRATEGY = "vanguard"; | ||
|
||
export default function vanguard(options: VanguardOptions) { | ||
const authorizationApi = options.authorizationApi; | ||
const passport = options.passport; | ||
const wsFedIdpUrl = options.wsFedIdpUrl; | ||
const wsFedRealm = options.wsFedRealm; | ||
const wsFedCertificate = options.wsFedCertificate; | ||
const externalAuthHome = options.externalAuthHome; | ||
|
||
// const loginBaseUrl = `${externalAuthHome}/login`; | ||
nahidakbar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!wsFedIdpUrl || !wsFedRealm || !wsFedCertificate) { | ||
return undefined; | ||
} | ||
|
||
passport.use( | ||
STRATEGY, | ||
new Strategy( | ||
{ | ||
identityProviderUrl: wsFedIdpUrl, | ||
realm: wsFedRealm, | ||
protocol: "wsfed", | ||
cert: wsFedCertificate | ||
}, | ||
function(profile: any, cb: Function) { | ||
const email = | ||
profile[ | ||
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" | ||
]; | ||
const displayName = | ||
profile[ | ||
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" | ||
] || email; | ||
const id = | ||
profile[ | ||
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier" | ||
]; | ||
profile = Object.assign(profile, { | ||
emails: [{ value: email }], | ||
displayName, | ||
id | ||
}); | ||
createOrGetUserToken(authorizationApi, profile, "vanguard") | ||
.then(userId => cb(null, userId)) | ||
.catch(error => cb(error)); | ||
} | ||
) | ||
); | ||
|
||
const router: Router = express.Router(); | ||
|
||
router.all("/", (req, res, next) => { | ||
passport.authenticate(STRATEGY, {})(req, res, next); | ||
}); | ||
|
||
router.all( | ||
"/return", | ||
passport.authenticate(STRATEGY, { | ||
failureRedirect: "/", | ||
failureFlash: true | ||
}), | ||
function(req, res) { | ||
redirectOnSuccess(req.query.redirect || externalAuthHome, req, res); | ||
} | ||
); | ||
|
||
return router; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might need to fork our version of this with the x509 and cryptiles problems patched out :(. No need for you to get to this before you go though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth0/passport-wsfed-saml2#129
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will native x509 dependency cause problems? It just needs build tools for npm install.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it breaks on node > 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a PR to get rid of it, but it's been sitting since October :(