Skip to content

Commit

Permalink
fix: patch saml dependency for clock skew
Browse files Browse the repository at this point in the history
  • Loading branch information
piejanssens committed Mar 23, 2023
1 parent 64c881b commit 82ec257
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ $ sf-oauth [--port]
🚀 SAML Assertion OAuth access token generator listening on port 3000
```
You can call th
| method | path | purpose | body/query parameters |
| ------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
| GET | `/authorize` | requests to supply `userId` via your browser, generates SAML assertion, requests OAuth access token from SF and then returns the access token | `client_id`, `scope`, `state` |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"bin": "./src/cli.js",
"scripts": {
"start": "node ./src/serve.js",
"semantic-release": "semantic-release"
"semantic-release": "semantic-release",
"postinstall": "npx patch-package"
},
"keywords": [
"SuccessFactors",
Expand Down
13 changes: 13 additions & 0 deletions patches/saml+3.0.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/saml/lib/saml20.js b/node_modules/saml/lib/saml20.js
index 9db8141..5ba6ec3 100644
--- a/node_modules/saml/lib/saml20.js
+++ b/node_modules/saml/lib/saml20.js
@@ -168,7 +168,7 @@ function createAssertion(options, strategies, callback) {
var confirmationData = doc.documentElement.getElementsByTagName('saml:SubjectConfirmationData');

if (options.lifetimeInSeconds) {
- conditions[0].setAttribute('NotBefore', now.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'));
+ conditions[0].setAttribute('NotBefore', now.clone().subtract(1, "days").format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'));
conditions[0].setAttribute('NotOnOrAfter', now.clone().add(options.lifetimeInSeconds, 'seconds').format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'));

confirmationData[0].setAttribute('NotOnOrAfter', now.clone().add(options.lifetimeInSeconds, 'seconds').format('YYYY-MM-DDTHH:mm:ss.SSS[Z]'));

0 comments on commit 82ec257

Please sign in to comment.