From 5549c84f2d6bcb10ad4853a908c18460c0cecd87 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Fri, 19 Sep 2025 20:08:55 +1000 Subject: [PATCH 1/3] Update documentation for Express v5 --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 3ca7f2d88..af5d77937 100644 --- a/README.md +++ b/README.md @@ -179,9 +179,12 @@ object that represents the user. You need to provide a route corresponding to the `path` configuration parameter given to the strategy: +#### Express v4.x + The authentication callback must be invoked after the `body-parser` middleware. ```javascript +// Express v4 const bodyParser = require("body-parser"); app.post( @@ -197,6 +200,28 @@ app.post( ); ``` +#### Express v5.x + +The authentication callback must be invoked after the `express.urlencoded({ extended: false })` middleware. + +```javascript +// Express v5 +const bodyParser = require("body-parser"); + +app.post( + "/login/callback", + express.urlencoded({ extended: false }), + passport.authenticate("saml", { + failureRedirect: "/", + failureFlash: true, + }), + function (req, res) { + res.redirect("/"); + }, +); +``` + + ### Authenticate requests Use `passport.authenticate()`, specifying `saml` as the strategy: From 11eec9881081b7eb1708ce317934ee148b6fcfe1 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Fri, 19 Sep 2025 20:14:38 +1000 Subject: [PATCH 2/3] Fix linting issues --- CHANGELOG.md | 2 +- README.md | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d5128035..6360fb63c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,7 +127,7 @@ #### 💣 Major Changes -- deps: use node-saml v4. See node-saml changelog for breaking changes: https://github.com/node-saml/node-saml/blob/master/CHANGELOG.md#v400-2022-10-28 [#796](https://github.com/node-saml/passport-saml/pull/796) +- deps: use node-saml v4. See node-saml changelog for breaking changes: https://github.com/node-saml/node-saml/blob/master/CHANGELOG.md#v400-2022-10-28 [#796](https://github.com/node-saml/passport-saml/pull/796) - Update node-saml to beta 5 -- See node-saml changelog for breaking changes [#783](https://github.com/node-saml/passport-saml/pull/783) - Update node-saml dependency [#770](https://github.com/node-saml/passport-saml/pull/770) - Update to support node-saml@4.0.0-beta.3 [#707](https://github.com/node-saml/passport-saml/pull/707) diff --git a/README.md b/README.md index af5d77937..771165c99 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ strategy: The authentication callback must be invoked after the `body-parser` middleware. ```javascript -// Express v4 +// Express v4 const bodyParser = require("body-parser"); app.post( @@ -205,11 +205,11 @@ app.post( The authentication callback must be invoked after the `express.urlencoded({ extended: false })` middleware. ```javascript -// Express v5 +// Express v5 const bodyParser = require("body-parser"); app.post( - "/login/callback", + "/login/callback", express.urlencoded({ extended: false }), passport.authenticate("saml", { failureRedirect: "/", @@ -221,7 +221,6 @@ app.post( ); ``` - ### Authenticate requests Use `passport.authenticate()`, specifying `saml` as the strategy: From f49e57c4229116979cca3887a2d4d4ebb303d762 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Fri, 9 Jan 2026 19:37:16 +1100 Subject: [PATCH 3/3] Remove unnecessary import from express 5 example --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 771165c99..d733e31eb 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,6 @@ The authentication callback must be invoked after the `express.urlencoded({ exte ```javascript // Express v5 -const bodyParser = require("body-parser"); - app.post( "/login/callback", express.urlencoded({ extended: false }),