Skip to content

Commit

Permalink
[#174991105] Upgrade passport-saml dependency to v1.3.5 (#60)
Browse files Browse the repository at this point in the history
* [#174991105] Upgrade passport-saml dependency to v1.3.5

* [#174991105] Update README, tip for errors on cached containers

Co-authored-by: Emanuele De Cupis <ema.decu@gmail.com>
  • Loading branch information
BurnedMarshal and balanza committed Aug 18, 2021
1 parent 4055d06 commit 9d677aa
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 45 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ Beware that any changes to the method signatures of
[`CustomSamlClient`](./strategy/saml_client.ts) class.

That's why the version of passport-saml in package.json is currently fixed at
`1.2.0`.
`1.3.5`.

## Local development

To run the project locally with the embedded example express application run the following commands:

```sh
yarn install
yarn build
docker-compose up --build
```

PS. If was present locally a previously cached version of `io-spid-commons` docker container and you get the error `Unexpected token <` on `node_modules/xml-encription/lib/templates/encrypted-key.tpl.xml.js`, is needed to clean all the old containers datas with `docker system prune --all` before running the project again.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"node-fetch": "^2.2.0",
"node-forge": "^0.10.0",
"passport": "^0.4.1",
"passport-saml": "1.2.0",
"passport-saml": "1.3.5",
"redis": "^2.8.0",
"winston": "^3.0.0",
"xml-crypto": "^1.4.0",
Expand Down
1 change: 1 addition & 0 deletions src/@types/passport-saml/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare module "passport-saml" {
generateAuthorizeRequest(
req: express.Request,
isPassive: boolean,
isHttpPostBinding: boolean,
callback: (err: Error, xml?: string) => void
): void;
}
Expand Down
1 change: 1 addition & 0 deletions src/strategy/__mocks__/passport-saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class SAML {
public generateAuthorizeRequest(
req: express.Request,
isPassive: boolean,
isHttpPostBinding: boolean,
callback: (err: Error | null, xml?: string) => void
): void {
mockWrapCallback(callback);
Expand Down
18 changes: 9 additions & 9 deletions src/strategy/__tests__/saml_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ describe("SAML prototype arguments check", () => {
OriginalPassportSaml.SAML.prototype.validatePostResponse
).toHaveLength(2);
});
it("should SAML generateAuthorizeRequest has 3 parameters", () => {
it("should SAML generateAuthorizeRequest has 4 parameters", () => {
expect(
OriginalPassportSaml.SAML.prototype.generateAuthorizeRequest
).toHaveLength(3);
).toHaveLength(4);
});
});

Expand Down Expand Up @@ -211,7 +211,7 @@ describe("CustomSamlClient#validatePostResponse", () => {
expect.any(Function)
);
expect(mockedCallback).toBeCalledWith(null, {}, false);
resolve();
resolve(undefined);
}, 100);
});
});
Expand Down Expand Up @@ -252,7 +252,7 @@ describe("CustomSamlClient#validatePostResponse", () => {
`SAML#ExtendedRedisCacheProvider: remove() error ${expectedDelError}`
)
);
resolve();
resolve(undefined);
}, 100);
});
});
Expand All @@ -274,7 +274,7 @@ describe("CustomSamlClient#generateAuthorizeRequest", () => {
{ validateInResponseTo: true },
redisCacheProvider
);
customSamlClient.generateAuthorizeRequest(req, false, mockCallback);
customSamlClient.generateAuthorizeRequest(req, false, true, mockCallback);
expect(mockCallback).toBeCalledWith(null, expectedXML);
});

Expand All @@ -299,14 +299,14 @@ describe("CustomSamlClient#generateAuthorizeRequest", () => {
redisCacheProvider,
mockAuthReqTampener
);
customSamlClient.generateAuthorizeRequest(req, false, mockCallback);
customSamlClient.generateAuthorizeRequest(req, false, true, mockCallback);
expect(mockAuthReqTampener).toBeCalledWith(SAMLRequest);
// Before checking the execution of the callback we must await that the TaskEither execution is completed.
await new Promise(resolve => {
setTimeout(() => {
expect(mockSet).toBeCalled();
expect(mockCallback).toBeCalledWith(null, SAMLRequest);
resolve();
resolve(undefined);
}, 100);
});
});
Expand All @@ -333,14 +333,14 @@ describe("CustomSamlClient#generateAuthorizeRequest", () => {
redisCacheProvider,
mockAuthReqTampener
);
customSamlClient.generateAuthorizeRequest(req, false, mockCallback);
customSamlClient.generateAuthorizeRequest(req, false, true, mockCallback);
expect(mockAuthReqTampener).toBeCalledWith(SAMLRequest);
// Before checking the execution of the callback we must await that the TaskEither execution is completed.
await new Promise(resolve => {
setTimeout(() => {
expect(mockSet).not.toBeCalled();
expect(mockCallback).toBeCalledWith(expectedTamperError);
resolve();
resolve(undefined);
}, 100);
});
});
Expand Down
8 changes: 7 additions & 1 deletion src/strategy/saml_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class CustomSamlClient extends PassportSaml.SAML {
public generateAuthorizeRequest(
req: express.Request,
isPassive: boolean,
isHttpPostBinding: boolean,
callback: (err: Error, xml?: string) => void
): void {
const newCallback = fromNullable(this.tamperAuthorizeRequest)
Expand All @@ -87,6 +88,11 @@ export class CustomSamlClient extends PassportSaml.SAML {
: callback(e);
})
.getOrElse(callback);
super.generateAuthorizeRequest(req, isPassive, newCallback);
super.generateAuthorizeRequest(
req,
isPassive,
isHttpPostBinding,
newCallback
);
}
}
48 changes: 15 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,6 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==

async@^2.1.5:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
dependencies:
lodash "^4.17.14"

async@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.1.tgz#d3274ec66d107a47476a4c49136aacdb00665fc8"
Expand Down Expand Up @@ -1786,11 +1779,6 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=

ejs@^2.5.6:
version "2.7.4"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.4.tgz#48661287573dcc53e366c7a1ae52c3a120eec9ba"
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==

electron-to-chromium@^1.3.793:
version "1.3.810"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.810.tgz#23e340507e13e48debdb7445d2f8fbfab681c4df"
Expand Down Expand Up @@ -1891,7 +1879,7 @@ escape-goat@^2.0.0:
resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675"
integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==

escape-html@~1.0.3:
escape-html@^1.0.3, escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
Expand Down Expand Up @@ -3775,7 +3763,7 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.19, lodash@^4.5.0:
lodash@^4.17.13, lodash@^4.17.19, lodash@^4.5.0:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -4072,11 +4060,6 @@ node-forge@^0.10.0:
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==

node-forge@^0.7.0:
version "0.7.6"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.7.6.tgz#fdf3b418aee1f94f0ef642cd63486c77ca9724ac"
integrity sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -4433,16 +4416,16 @@ pascalcase@^0.1.1:
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=

passport-saml@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/passport-saml/-/passport-saml-1.2.0.tgz#45900e42ce57186be43be835147546d941095d71"
integrity sha512-CU1JOx9FTITF8+vl/G1g7FV6kHWXYzECV3pq3D8K3RIM1MS0efbfQ2hkgDFdoZGdG9DdMH5z8OBW/O8qoXnkLQ==
passport-saml@1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/passport-saml/-/passport-saml-1.3.5.tgz#747f2c8bb8b9fed41e8cd14586df5aa83e8a8996"
integrity sha512-HFamiqgGiMRCbUBm3wx02WYWKb6ojke0WJHrg4QXI8tx35HrTmDiY8MksUXhouJtEkfcRwXjBL2cSEpRQ6+PgQ==
dependencies:
debug "^3.1.0"
passport-strategy "*"
q "^1.5.0"
xml-crypto "^1.1.4"
xml-encryption "^0.11.0"
xml-crypto "^1.4.0"
xml-encryption "1.2.1"
xml2js "0.4.x"
xmlbuilder "^11.0.0"
xmldom "0.1.x"
Expand Down Expand Up @@ -6059,22 +6042,21 @@ xdg-basedir@^4.0.0:
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==

xml-crypto@^1.1.4, xml-crypto@^1.4.0:
xml-crypto@^1.4.0:
version "1.5.4"
resolved "https://registry.yarnpkg.com/xml-crypto/-/xml-crypto-1.5.4.tgz#f204086120565fa8f186fc6f05492f9a71cb72ca"
integrity sha512-0MP/Tgrvjeqy4IXJ2pGrlSh5LHol70TLtAkyqkr2bmU5iv0M7UBihTstsa3eKE0jbagigElBDBN0d7L05oJL0A==
dependencies:
xmldom "^0.6.0"
xpath "0.0.27"

xml-encryption@^0.11.0:
version "0.11.2"
resolved "https://registry.yarnpkg.com/xml-encryption/-/xml-encryption-0.11.2.tgz#c217f5509547e34b500b829f2c0bca85cca73a21"
integrity sha512-jVvES7i5ovdO7N+NjgncA326xYKjhqeAnnvIgRnY7ROLCfFqEDLwP0Sxp/30SHG0AXQV1048T5yinOFyvwGFzg==
xml-encryption@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/xml-encryption/-/xml-encryption-1.2.1.tgz#e6d18817c4309fd07ca7793cca93c3fd06745baa"
integrity sha512-hn5w3l5p2+nGjlmM0CAhMChDzVGhW+M37jH35Z+GJIipXbn9PUlAIRZ6I5Wm7ynlqZjFrMAr83d/CIp9VZJMTA==
dependencies:
async "^2.1.5"
ejs "^2.5.6"
node-forge "^0.7.0"
escape-html "^1.0.3"
node-forge "^0.10.0"
xmldom "~0.1.15"
xpath "0.0.27"

Expand Down

0 comments on commit 9d677aa

Please sign in to comment.