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

Separated functional tests from unit tests and added extra validation #50

Open
wants to merge 223 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
d31386b
change package innfo
woloski Aug 27, 2012
8258295
support for thumbprint check
woloski Aug 27, 2012
863269f
adding audience check
woloski Aug 27, 2012
25d8ccd
update readme and bump to 0.2 with support of audience uri and expira…
woloski Aug 27, 2012
44e009c
support for saml 1.1 assertions
woloski Dec 9, 2012
c645165
bump to 0.3.0
woloski Dec 9, 2012
fbf2457
support for claimtypes with multiple values
woloski Dec 10, 2012
20e6b90
bump 0.3.1
woloski Dec 10, 2012
c140250
add nameid
woloski Dec 10, 2012
b9f7700
support assertions with just one attribute
woloski Dec 17, 2012
884d0bd
bump 0.3.3
woloski Dec 17, 2012
90d91d4
add tests and fix nameidentifier parsing in case Format attribute is …
woloski Mar 14, 2013
d787ee9
0.3.5
woloski Mar 14, 2013
3d8d893
add wreply parameter
jfromaniello Mar 19, 2013
147288a
Merge pull request #1 from jfromaniello/master
woloski Mar 19, 2013
68637e2
allow custom options when authorizing
jfromaniello Mar 29, 2013
5e9f4e1
0.3.6
jfromaniello Mar 29, 2013
565a305
fix xmldom dep to 0.1.13 and add validation of an office365 assertion
woloski Apr 2, 2013
bae091a
add authorizationParams method
jfromaniello Apr 3, 2013
55d3a8a
0.3.8
jfromaniello Apr 3, 2013
f8a7789
Add support for configurable xpath to the Signature and a callback to…
dboardma May 6, 2013
f9a872a
fix issue when request is post but there is no wresult, added integra…
woloski May 6, 2013
73db600
add travis
woloski May 6, 2013
929d731
add should in dev deps
woloski May 6, 2013
8bf5a70
Merge pull request #2 from dboardma/master
woloski May 6, 2013
2cbc043
bump to 0.3.10
woloski May 6, 2013
208ea47
should redirect to idp if is a post but wresult is missing
woloski May 6, 2013
86f8e81
bump to 0.3.11
woloski May 6, 2013
eaaba39
skip undefined attributes
jfromaniello Jun 10, 2013
8ff069e
0.3.12
jfromaniello Jun 10, 2013
c1555bf
samlp implementation Redirect-POST binding
woloski May 10, 2013
737ad72
saml2 assertion validation tests
woloski May 10, 2013
5142ec0
saml2 tests, unicode tests, change the way we handle errors
woloski Jun 14, 2013
94dabcb
refactoring to support signed responses and assertions smarter
woloski Jul 8, 2013
bdfb6df
bump to 0.6.0
woloski Jul 8, 2013
4a87390
more interop testing
woloski Jul 9, 2013
fde5aea
change the assertion is parsed to use DOM instead of xml2js
woloski Aug 7, 2013
6241c8a
bump to 0.7.0
woloski Aug 7, 2013
a0c100e
add done(error) on test failing on travis
woloski Aug 7, 2013
4e26338
fix broken test
jfromaniello Sep 6, 2013
bc18dc5
0.7.1
jfromaniello Sep 6, 2013
04e9293
add jwt support
jfromaniello Sep 6, 2013
3693427
0.8.0
jfromaniello Sep 6, 2013
4843373
add jwt to doco
jfromaniello Sep 6, 2013
22b5ba8
0.8.1
jfromaniello Sep 6, 2013
8c6464d
support for samlp requests when idp has question mark in URL like ping
woloski Nov 22, 2013
af7af0c
bump to 0.8.2
woloski Nov 22, 2013
3d73e12
validate if saml response contains assertion element
siacomuzzi Jan 20, 2014
258272e
0.8.3
siacomuzzi Jan 20, 2014
4727b00
support encrypted assertions. closes #3
siacomuzzi Feb 25, 2014
baf14c8
0.8.4
siacomuzzi Feb 25, 2014
5607542
minor
siacomuzzi Feb 25, 2014
c9081be
minor
siacomuzzi Feb 25, 2014
af3f4ed
minor fix
siacomuzzi Feb 25, 2014
bff9bbf
0.8.5
siacomuzzi Feb 25, 2014
64ccbd3
code improvements
siacomuzzi Feb 25, 2014
85fce31
0.8.6
siacomuzzi Feb 25, 2014
769583a
ensure assertion xmldom object
siacomuzzi Feb 25, 2014
c931e02
0.8.7
siacomuzzi Feb 25, 2014
4019a8e
xml-encryption: ~0.3.5
siacomuzzi Mar 5, 2014
a314ac3
0.8.8
siacomuzzi Mar 5, 2014
9228b22
latest xmlenc with autopadding option
woloski Mar 10, 2014
b17ff64
0.8.9
woloski Mar 10, 2014
9557eb4
update to xml-encryption 0.6.0
woloski Mar 29, 2014
ca41ae4
0.9.0
woloski Mar 29, 2014
bee0d54
move to our own xmldom that support xml entities encoded using ª…
woloski Apr 9, 2014
dc7885c
authorizationParams: return all options
siacomuzzi Apr 14, 2014
b9364b7
0.10.1
siacomuzzi Apr 14, 2014
dd20579
move to xml-encryption 0.7.* which handles padding and utf8 better
woloski Apr 16, 2014
3a84079
0.11.0
woloski Apr 16, 2014
fadefc3
add support for custom assertion request
jfromaniello Jun 6, 2014
6c40c68
0.12.0
jfromaniello Jun 6, 2014
0aad2de
add optional requestContext to generate the request xml
jfromaniello Jun 16, 2014
e97148c
0.12.1
jfromaniello Jun 16, 2014
f296e03
0.13.0
jfromaniello Jun 16, 2014
f023bc8
fix issue with string interpolation
jfromaniello Jun 17, 2014
966f5f6
0.13.1
jfromaniello Jun 17, 2014
0b3857b
remove lodash dep
jfromaniello Jun 17, 2014
c54ead1
0.13.2
jfromaniello Jun 17, 2014
6df1788
return authnContext as another attribute of the user
woloski Jul 1, 2014
b3958ea
0.14.0
woloski Jul 1, 2014
dd70863
add sessionIndex as another attribute
jfromaniello Jul 2, 2014
ce2d6d9
0.15.0
jfromaniello Jul 2, 2014
0462e18
add nameIdAttributes in the profile
jfromaniello Jul 4, 2014
ec850d9
0.16.0
jfromaniello Jul 4, 2014
5de6834
update to latest jsonwebtoken
woloski Jul 14, 2014
d88bac4
0.16.1
woloski Jul 14, 2014
1a7e9ea
update xml-crypto that has a fix to replace crlf with lf only
woloski Aug 12, 2014
646fa67
0.17.0
woloski Aug 12, 2014
e1ef74a
add test and fix for assertion containing \r\n
woloski Aug 12, 2014
920c1db
0.18.0
woloski Aug 12, 2014
56d664a
0.18.1
woloski Aug 12, 2014
3645a6f
add ForceAuthn and an Auth0 example
jfromaniello Aug 18, 2014
2712f7c
0.19.0
jfromaniello Aug 18, 2014
c0f2e81
update jsonwebtoken
jfromaniello Dec 30, 2014
14570e8
1.0.0
jfromaniello Dec 30, 2014
4bac11c
minor
jfromaniello Dec 30, 2014
b34f8e2
Updated to use Express ^4.11
mithun-daa Jan 19, 2015
a81851e
handle error when RequestedSecurityToken is not part of wresult
siacomuzzi Jan 21, 2015
66f7de1
1.0.1
siacomuzzi Jan 21, 2015
e8f046e
support array of thumbprints
siacomuzzi Mar 12, 2015
ac5d691
1.1.0
siacomuzzi Mar 12, 2015
c92bc7b
support signed SAMLRequest
siacomuzzi Mar 18, 2015
a3dd79c
1.2.0
siacomuzzi Mar 18, 2015
9ec1503
support sign samlRequest for deflate encoding
siacomuzzi Mar 23, 2015
856a3b6
1.3.0
siacomuzzi Mar 23, 2015
50099d0
minor improvements and bug fixing
siacomuzzi Mar 24, 2015
e3dae31
1.3.1
siacomuzzi Mar 24, 2015
51f205c
avoid uncaughtException
siacomuzzi Apr 16, 2015
716100f
1.3.2
siacomuzzi Apr 16, 2015
99dcee5
Added support for SAML Responses with no embedded signatures
eugeniop May 28, 2015
e191a00
Added interop tests
eugeniop May 28, 2015
ae2a4ca
Merge pull request #16 from auth0/non-embedded-signatures
woloski May 28, 2015
3113751
1.3.3
woloski May 28, 2015
a8b4c00
minor
jfromaniello Jun 11, 2015
e1ec219
1.3.4
jfromaniello Jun 11, 2015
4bb7459
saml11: fix nameIdentifier resolver
siacomuzzi Jun 15, 2015
4305d92
1.3.5
siacomuzzi Jun 15, 2015
9f6038b
update jsonwebtoken
jfromaniello Jul 16, 2015
268c138
2.0.0
jfromaniello Jul 16, 2015
9d1a604
accept RelayState from options.identityProviderUrl
siacomuzzi Jul 23, 2015
c6891e0
2.0.1
siacomuzzi Jul 23, 2015
a78c6a0
Added support for ws-trust 1.3 namespace
eugeniop Aug 29, 2015
2d1041c
rename wsfed-result test file
siacomuzzi Aug 30, 2015
bd7dce9
Merge pull request #18 from auth0/ws-trust1-3
siacomuzzi Aug 30, 2015
94075b9
add AuthnContext macro for options.requestTemplate
siacomuzzi Aug 31, 2015
1fadad0
2.1.0
siacomuzzi Aug 31, 2015
a860015
use empty string as default value for @@AuthnContext@@
siacomuzzi Sep 1, 2015
540caf2
2.1.1
siacomuzzi Sep 1, 2015
c291f19
samlp: check for AuthnFailed status
siacomuzzi Oct 8, 2015
ba7bec3
2.2.0
siacomuzzi Oct 8, 2015
6640ca8
return 401 if AuthenticationFailedError
siacomuzzi Oct 8, 2015
9e4eeaf
2.2.1
siacomuzzi Oct 8, 2015
ff3d599
improve HTTP-POST binding support
siacomuzzi Nov 11, 2015
6f02846
2.3.0
siacomuzzi Nov 11, 2015
56ebd05
updated to passport@0.3.2
siacomuzzi Nov 19, 2015
55cf1e9
2.4.0
siacomuzzi Nov 19, 2015
fbfeee4
use passport-strategy instead of passport
siacomuzzi Nov 19, 2015
ae68ae8
Merge pull request #21 from auth0/passport_strategy
jaredhanson Nov 19, 2015
ba3ae5b
2.5.0
siacomuzzi Nov 19, 2015
9600492
xml-encryption@0.7.4
siacomuzzi Dec 28, 2015
50c8867
2.5.1
siacomuzzi Dec 28, 2015
6cdffa9
Updates license and edits readme
Jan 12, 2016
34da02a
Merge pull request #23 from aguerere/master
siacomuzzi Jan 13, 2016
2d332a4
point to specified tarball of xml-crypto
siacomuzzi Jan 28, 2016
30d5897
2.6.0
siacomuzzi Jan 28, 2016
6215e7a
support SAMLResponse with signed assertion and "ds" prefix defined on…
siacomuzzi Feb 1, 2016
293ea2c
2.7.0
siacomuzzi Feb 1, 2016
1f6582e
Added strategies for ADFS WS-Fed and SAMLp
siacomuzzi Feb 23, 2016
1b994c1
should validate thumbprint always for embedded signatures (even if ce…
siacomuzzi Feb 24, 2016
9e0f439
2.8.0
siacomuzzi Feb 24, 2016
9e2ee1e
Merge pull request #9 from mithun-daa/master
siacomuzzi Mar 14, 2016
35ddfc4
saml: fixed normalization of special characters according to spec
siacomuzzi Mar 18, 2016
7c8325e
2.9.0
siacomuzzi Mar 18, 2016
d3e1c99
SAMLRequest: Signature element must be located after Issuer
siacomuzzi Mar 31, 2016
086bd47
2.10.0
siacomuzzi Mar 31, 2016
c5b10a4
implement pluggable state store
siacomuzzi Apr 5, 2016
045f32c
2.11.0
siacomuzzi Apr 5, 2016
86bc854
avoid uncaught from signature generation
siacomuzzi Apr 6, 2016
6a7405e
2.11.1
siacomuzzi Apr 6, 2016
351dd2d
xml-encryption 0.8.0
siacomuzzi Apr 29, 2016
ee84a37
2.11.2
siacomuzzi Apr 29, 2016
f4b5a16
return HTTP 400 is saml response contains multiple Assertion/Encrypte…
siacomuzzi May 26, 2016
3cff746
2.11.3
siacomuzzi May 26, 2016
a690f2c
expose samlp
woloski May 29, 2016
3d06bda
2.11.4
woloski May 29, 2016
d10c28f
Updated validateSamlResponse to check status:Success before extractin…
Jun 1, 2016
330663c
Merge pull request #31 from auth0/saml-assertion-error-update
siacomuzzi Jun 3, 2016
7af3a16
2.11.5
siacomuzzi Jun 3, 2016
3ad0121
Add fault check support
ziluvatar Jun 8, 2016
ec31177
Merge pull request #32 from ziluvatar/wsfed-add-fault-support
Jun 8, 2016
3df3060
2.11.6
Jun 8, 2016
b3baf63
Updated passport library to add extra validation to the SAMLResponse …
Jul 13, 2016
30611db
Updated passport library to add extra validation to the SAMLResponse …
Jul 13, 2016
e5deb30
Added winston logging
Jul 25, 2016
5e034bf
Refactor to reduce PR diff
Jul 25, 2016
9ed9543
Added more comments
Jul 25, 2016
07c53fa
Replaced winston with event emitter
Jul 29, 2016
3e03dbc
Added isValidResponseId method
Jul 29, 2016
17b7f2b
Added unit test
Jul 29, 2016
7ec2806
Included inresponseto validation
Jul 29, 2016
1a8b137
Moved validation and fixed test
Jul 29, 2016
853b9af
Moved request_id to strategy
Jul 29, 2016
dfba502
Added validation for NameQualifier and SPNameQualifier
Aug 2, 2016
7253253
add license to package.json
anotheredward Aug 29, 2016
120f5b2
Merge pull request #37 from anotheredward/patch-1
siacomuzzi Aug 30, 2016
3c49cea
Revert "add license to package.json"
siacomuzzi Aug 30, 2016
5851039
Merge pull request #38 from auth0/revert-37-patch-1
siacomuzzi Aug 30, 2016
af72ccc
Updated xml-crypto library
Sep 1, 2016
e9e1844
Fixed issue with namespace defined in response causing digest issues …
Sep 2, 2016
70ab8ad
Fixed IBM saml responses
Sep 6, 2016
a2ee3cb
Support passReqToCallback option.
Sep 15, 2016
bc8a73d
Merge pull request #41 from sjudson-auth0/add-prtc
jaredhanson Sep 15, 2016
77ec755
Added flags to disable NameQualifier validation
Sep 28, 2016
bcdc796
Updated namequalifier and spnamequalifier validations to only apply t…
Sep 29, 2016
9b2aeee
Added try/catch to prevent throwing when parsing saml response
Oct 19, 2016
5e21379
Moved var outside try/catch
Oct 20, 2016
6466249
Added flag to enable/disable validation
Oct 20, 2016
79d0ac4
Added logging to parse assertion
Nov 1, 2016
8228345
Fixed signature issue in SMAL request and improved error messages'
Jan 13, 2017
4ac88f2
Fixed names of tests and endpoint
Jan 13, 2017
97d4bd1
Fix for node 6.x. Be explicit about crypto update input encoding latin1
dschenkelman Jan 20, 2017
bc922e1
Merge pull request #1 from dschenkelman/node6fix
Jan 20, 2017
11cedb4
Updated older dependencies that raised issues with Snyk
eugeniop May 11, 2017
dbbf544
Bumped minor after dependencies update
eugeniop May 11, 2017
e28158a
Merge pull request #46 from eugeniop/master
siacomuzzi May 11, 2017
5e8c8b6
Better error handing when xml (wresult/SAMLResponse) is invalid
sandrinodimattia May 24, 2017
99ae837
Indentation to spaces
sandrinodimattia May 24, 2017
6fff398
Indentation to spaces
sandrinodimattia May 24, 2017
5a1b13e
Added tests for the XML parsers and the way the handle errors
sandrinodimattia May 24, 2017
89c60cf
Indentation using spaces
sandrinodimattia May 24, 2017
d47901d
Removed yarn.lock
sandrinodimattia May 24, 2017
e92272d
Add support for ProviderName option
jhiner Jun 3, 2017
cb87960
Bumped xml-crypto to the latest version
Jun 8, 2017
4f659ac
Merge pull request #48 from mcastany/bump-xml-crypto-library
glena Jun 8, 2017
56732c6
2.13.0
Jun 8, 2017
6f0cc49
Merge pull request #49 from jhiner/add-providername
Jun 9, 2017
85342f0
Uncommented errors, moved flag after validation
Jun 14, 2017
6914b81
Merge branch 'master' into various-improvements
Jun 14, 2017
66e6a18
Merge pull request #47 from sandrinodimattia/invalid-xml-handling
Jun 14, 2017
a211d94
Merge branch 'master' into various-improvements
Jun 14, 2017
2b9ab19
Merge pull request #51 from mcastany/various-improvements
glena Jun 14, 2017
556c8c9
Separated functional tests from unit tests and added extra validation
Jun 9, 2017
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.DS_Store
39 changes: 39 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"camelcase": false,
"curly": false,

"node": true,
"esnext": true,
"bitwise": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": false,
"newcap": true,
"noarg": true,
"regexp": true,
"undef": true,
"strict": false,
"smarttabs": true,
"expr": true,

"evil": true,
"browser": true,
"regexdash": true,
"wsh": true,
"trailing": true,
"sub": true,
"unused": true,
"laxcomma": true,
"nonbsp": true,

"globals": {
"after": false,
"before": false,
"afterEach": false,
"beforeEach": false,
"describe": false,
"it": false,
"escape": false
}
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
before_install: npm i -g npm@1.4.28
node_js:
- 4
- 6
27 changes: 14 additions & 13 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
(The MIT License)
The MIT License (MIT)

Copyright (c) 2011 Matias Woloski (Auth10)
Copyright (c) 2015 Auth0, Inc. <support@auth0.com> (http://auth0.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
80 changes: 78 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Passport-wsfed-saml2
=============

[![Build Status](https://travis-ci.org/auth0/passport-wsfed-saml2.png)](https://travis-ci.org/auth0/passport-wsfed-saml2)

This is a ws-federation protocol + SAML2 tokens authentication provider for [Passport](http://passportjs.org/).

The code was originally based on Henri Bergius's [passport-saml](https://github.com/bergie/passport-saml) library.
Expand All @@ -15,7 +17,7 @@ Passport-wsfed-saml2 has been tested to work with both [Windows Azure Active Dir

### Configure strategy

This example utilizes a development namespace (auth10-dev) on [Windows Azure Access Control Service](https://www.windowsazure.com/en-us/home/features/identity/) and is using Google as the only identity provider configured for the sample application.
This example utilizes a development namespace (auth10-dev) on [Windows Azure Access Control Service](https://www.windowsazure.com/en-us/home/features/identity/) and is using Google as the only identity provider configured for the sample application.


```javascript
Expand Down Expand Up @@ -44,10 +46,84 @@ You need to provide a route corresponding to the `path` configuration parameter

```javascript
app.post('/login/callback',
passport.authenticate('wsfedsaml2', { failureRedirect: '/', failureFlash: true }),
passport.authenticate('wsfed-saml2', { failureRedirect: '/', failureFlash: true }),
function(req, res) {
res.redirect('/');
}
);
```

### Jwt

Although this started as wsfed&saml we added support for wsfed&jwt. Usage is

~~~javascript
passport.use(new wsfedsaml2(
{
jwt: {
//same options than node-jsonwebtoken
algorithm: 'RS256'
},
cert: 'MIIDFjCCAf6gAwIBAgIQDRRprj9lv5RBvaQdlFltDzANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyRhdXRoMTAtZGV2LmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTEwOTIxMDMzMjMyWhcNMTIwOTIwMDkzMjMyWjAvMS0wKwYDVQQDEyRhdXRoMTAtZGV2LmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCEIAEB/KKT3ehNMy2MQEyJIQ14CnZ8DC2FZgL5Gw3UBSdRb9JinK/gw7yOQtwKfJUqeoZaUSAAdcdbgqwVxOnMBfWiYX7DGlEznSfqYVnjOWjqqjpoe0h6RaOkdWovDtoidmqVV1tWRJFjkj895clPxkLpnqqcycfXtSdZen0SroGyirD2mhMc9ccLbJ3zRnBNjlvpo5zow1zYows09tNC2EhGROL/OS4JNRQnJRICZC+WkA7Igf3xb4btJOzIPYhFiqCGrd/81CHmAyEuNzyc60I5yomDQfZ91Eb5Uk3F7mlfAlYB2aZwDwldLSOlVE8G1E5xFexF/5KyPC4ShNodAgMBAAGjLjAsMAsGA1UdDwQEAwIE8DAdBgNVHQ4EFgQUyYfx/r0czsPgTzitqey+fGMQpkcwDQYJKoZIhvcNAQEFBQADggEBAB5dgQlM3tKS+/cjlvMCPjZH0Iqo/Wxecri3YWi2iVziZ/TQ3dSV+J/iTyduN7rJmFQzTsNERcsgyAwblwnEKXXvlWo8G/+VDIMh3zVPNQFKns5WPkfkhoSVlnZPTQ8zdXAcWgDXbCgvdqIPozdgL+4l0W0XVL1ugA4/hmMXh4TyNd9Qj7MWvlmwVjevpSqN4wG735jAZFHb/L/vvc91uKqP+JvLNj8tPFVxatzi56X1V8jBM61Hx1Z9D0RCDjtmcQVysVEylW9O6mNy6ZrhLm0q5yecWudfBbTKDqRoCHQRjrMU2c5q/ZFDtgjLim7FaNxFbgTyjeRCPclEhfemYVg='
},
function(profile, done) {
findByEmail(profile.email, function(err, user) {
if (err) {
return done(err);
}
return done(null, user);
});
})
));
~~~

### Configure strategy for ADFS (WS-Fed)

This example utilizes a strategy with ADFS using WS-Fed.

```javascript
passport.use('wsfed-saml2', new wsfedsaml2({
// ADFS RP identifier
realm: 'urn:node:wsfedapp',
identityProviderUrl: 'https://my-adfs/adfs/ls',
// ADFS token signing certificate
thumbprint: '5D27....D27E'
// or options.cert: fs.readFileSync("adfs_signing_key.cer")
}, function (profile, done) {
// ...
}));

```

### Configure strategy for ADFS (SAMLp)

This example utilizes a strategy using SAMLp and RP token encryption.

```javascript
passport.use('wsfed-saml2', new wsfedsaml2({
// ADFS RP identifier
realm: 'urn:node:samlapp',
identityProviderUrl: 'https://my-adfs/adfs/ls',
// ADFS token signing certificate
thumbprint: '5D27...D27E',
// or options.cert: fs.readFileSync("adfs_signing_key.cer")
protocol: "samlp",
// This is the private key (use case where ADFS
// is configured for RP token encryption)
decryptionKey: fs.readFileSync("server.key")
}, function (profile, done) {
// ...
}));
```

## Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.

## Author

[Auth0](auth0.com)

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
90 changes: 90 additions & 0 deletions examples/auth0/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
var express = require('express');
var passport = require('passport');
var Strategy = require('../../lib/passport-wsfed-saml2/index').Strategy;
var http = require('http');

passport.serializeUser(function(user, done) {
done(null, user);
});

passport.deserializeUser(function(id, done) {
done(null, id);
});

passport.use(new Strategy(
{
protocol: 'samlp',
path: '/login/callback',
realm: 'urn:saml-example',
homeRealm: '',
// identityProviderUrl: 'https://mdocs.auth0.com/samlp/dVrQZOG4gkBhzcLartSgW2v7kSnvW5XR?connection=github',
// thumbprint: 'c5b930896e3f4e2cc1d6d1ceb68f4d3de90deee6'
identityProviderUrl: 'https://login0.myauth0.com/samlp/wklezTET2P3iYA54Sraju8qFN0ohdI0G',
thumbprints: ['dba77ba142ff38d5076b4310700709c470d53790']
}, function(profile, done) {
console.log("Auth with", profile);
if (!profile.email) {
return done(new Error("No email found"), null);
}
done(null, profile);
}
));

var app = express();

// configure Express
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.logger());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(__dirname + '/../../public'));
});


app.get('/', function(req, res){
res.render('index', { user: req.user });
});

app.get('/account', ensureAuthenticated, function(req, res){
res.render('account', { user: req.user });
});

app.get('/login',
passport.authenticate('wsfed-saml2', { failureRedirect: '/', forceAuthn: true }),
function(req, res) {
res.redirect('/');
}
);

app.post('/login/callback',
passport.authenticate('wsfed-saml2', { failureRedirect: '/' }),
function(req, res) {
res.redirect('/');
}
);

app.get('/logout', function(req, res){
req.logout();
res.redirect('/');
});

http.createServer(app).listen(3000, function () {
console.log("Server listening in http://localhost:3000");
});

// Simple route middleware to ensure user is authenticated.
// Use this route middleware on any resource that needs to be protected. If
// the request is authenticated (typically via a persistent login session),
// the request will proceed. Otherwise, the user will be redirected to the
// login page.
function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login');
}
10 changes: 10 additions & 0 deletions examples/auth0/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "passport-azure-acs-sample",
"version": "0.0.0",
"dependencies": {
"express": ">= 0.0.0",
"ejs": ">= 0.0.0",
"passport": ">= 0.0.0",
"passport-azure-acs": ">= 0.0.0"
}
}
2 changes: 2 additions & 0 deletions examples/auth0/views/account.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>ID: <%= user.id %></p>
<p>Name: <%= user.displayName %></p>
5 changes: 5 additions & 0 deletions examples/auth0/views/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if (!user) { %>
<h2>Welcome! Please log in.</h2>
<% } else { %>
<h2>Hello, <%= user.email %>.</h2>
<% } %>
21 changes: 21 additions & 0 deletions examples/auth0/views/layout.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Passport-Windows Azure Access Control Service Example</title>
</head>
<body>
<% if (!user) { %>
<p>
<a href="/">Home</a> |
<a href="/login">Log In</a>
</p>
<% } else { %>
<p>
<a href="/">Home</a> |
<a href="/account">Account</a> |
<a href="/logout">Log Out</a>
</p>
<% } %>
<%- body %>
</body>
</html>
Loading