Skip to content

Commit d730639

Browse files
committed
Added a configuration option for passport-saml:
disableRequestedAuthnContext: true|false By default only Password authmethod is accepted, this option allows any other method. Issue and option described here: node-saml/passport-saml#226 Signed-off-by: Emmanuel Ormancey <emmanuel.ormancey@cern.ch>
1 parent 7f0fe69 commit d730639

File tree

6 files changed

+7
-1
lines changed

6 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ There are some config settings you need to change in the files below.
225225
| `CMD_SAML_IDPCERT` | `/path/to/cert.pem` | certificate file path of IdP in PEM format |
226226
| `CMD_SAML_ISSUER` | no example | identity of the service provider (optional, default: serverurl)" |
227227
| `CMD_SAML_IDENTIFIERFORMAT` | no example | name identifier format (optional, default: `urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`) |
228+
| `CMD_SAML_DISABLEREQUESTEDAUTHNCONTEXT` | `true` or `false` | true to allow any authentication method, false restricts to password authentication (PasswordProtectedTransport) method (default: false) |
228229
| `CMD_SAML_GROUPATTRIBUTE` | `memberOf` | attribute name for group list (optional) |
229230
| `CMD_SAML_REQUIREDGROUPS` | `Hackmd-users` | group names that allowed (use vertical bar to separate) (optional) |
230231
| `CMD_SAML_EXTERNALGROUPS` | `Temporary-staff` | group names that not allowed (use vertical bar to separate) (optional) |

config.json.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"idpCert": "change: certificate file path of IdP in PEM format",
9494
"issuer": "change or delete: identity of the service provider (default: serverurl)",
9595
"identifierFormat": "change or delete: name identifier format (default: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress')",
96+
"disableRequestedAuthnContext": "change or delete: true to allow any authentication method, false restricts to password authentication method (default: false)",
9697
"groupAttribute": "change or delete: attribute name for group list (ex: memberOf)",
9798
"requiredGroups": [ "change or delete: group names that allowed" ],
9899
"externalGroups": [ "change or delete: group names that not allowed" ],

lib/config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ module.exports = {
138138
idpCert: undefined,
139139
issuer: undefined,
140140
identifierFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
141+
disableRequestedAuthnContext: false,
141142
groupAttribute: undefined,
142143
externalGroups: [],
143144
requiredGroups: [],

lib/config/environment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ module.exports = {
115115
idpCert: process.env.CMD_SAML_IDPCERT,
116116
issuer: process.env.CMD_SAML_ISSUER,
117117
identifierFormat: process.env.CMD_SAML_IDENTIFIERFORMAT,
118+
disableRequestedAuthnContext: toBooleanConfig(process.env.CMD_SAML_DISABLEREQUESTEDAUTHNCONTEXT),
118119
groupAttribute: process.env.CMD_SAML_GROUPATTRIBUTE,
119120
externalGroups: toArrayConfig(process.env.CMD_SAML_EXTERNALGROUPS, '|', []),
120121
requiredGroups: toArrayConfig(process.env.CMD_SAML_REQUIREDGROUPS, '|', []),

lib/config/hackmdEnvironment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ module.exports = {
109109
idpCert: process.env.HMD_SAML_IDPCERT,
110110
issuer: process.env.HMD_SAML_ISSUER,
111111
identifierFormat: process.env.HMD_SAML_IDENTIFIERFORMAT,
112+
disableRequestedAuthnContext: toBooleanConfig(process.env.HMD_SAML_DISABLEREQUESTEDAUTHNCONTEXT),
112113
groupAttribute: process.env.HMD_SAML_GROUPATTRIBUTE,
113114
externalGroups: toArrayConfig(process.env.HMD_SAML_EXTERNALGROUPS, '|', []),
114115
requiredGroups: toArrayConfig(process.env.HMD_SAML_REQUIREDGROUPS, '|', []),

lib/web/auth/saml/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ passport.use(new SamlStrategy({
1717
entryPoint: config.saml.idpSsoUrl,
1818
issuer: config.saml.issuer || config.serverURL,
1919
cert: fs.readFileSync(config.saml.idpCert, 'utf-8'),
20-
identifierFormat: config.saml.identifierFormat
20+
identifierFormat: config.saml.identifierFormat,
21+
disableRequestedAuthnContext: config.saml.disableRequestedAuthnContext
2122
}, function (user, done) {
2223
// check authorization if needed
2324
if (config.saml.externalGroups && config.saml.groupAttribute) {

0 commit comments

Comments
 (0)