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

[NEW] Setting to configure custom authn context on SAML requests #14675

Merged
merged 5 commits into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions app/meteor-accounts-saml/server/saml_rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ Meteor.methods({
section: name,
i18nLabel: 'SAML_Custom_Logout_Behaviour',
});
settings.add(`SAML_Custom_${ name }_custom_authn_context`, 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Authn_Context',
});
},
});

Expand Down Expand Up @@ -149,6 +155,7 @@ const getSamlConfigs = function(service) {
mailOverwrite: settings.get(`${ service.key }_mail_overwrite`),
issuer: settings.get(`${ service.key }_issuer`),
logoutBehaviour: settings.get(`${ service.key }_logout_behaviour`),
customAuthnContext: settings.get(`${ service.key }_custom_authn_context`),
secret: {
privateKey: settings.get(`${ service.key }_private_key`),
publicCert: settings.get(`${ service.key }_public_cert`),
Expand Down Expand Up @@ -193,6 +200,7 @@ const configureSamlService = function(samlConfigs) {
cert: samlConfigs.secret.cert,
privateCert,
privateKey,
customAuthnContext: samlConfigs.customAuthnContext,
};
};

Expand Down
3 changes: 2 additions & 1 deletion app/meteor-accounts-saml/server/saml_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ SAML.prototype.generateAuthorizeRequest = function(req) {
request += `<samlp:NameIDPolicy xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Format="${ this.options.identifierFormat }" AllowCreate="true"></samlp:NameIDPolicy>\n`;
}

const authnContext = this.options.customAuthnContext || 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport';
request
+= '<samlp:RequestedAuthnContext xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Comparison="exact">'
+ '<saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef></samlp:RequestedAuthnContext>\n'
+ `<saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">${ authnContext }</saml:AuthnContextClassRef></samlp:RequestedAuthnContext>\n`
+ '</samlp:AuthnRequest>';

return request;
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,7 @@
"Same_As_Token_Sent_Via": "Same as \"Token Sent Via\"",
"Same_Style_For_Mentions": "Same style for mentions",
"SAML": "SAML",
"SAML_Custom_Authn_Context": "Custom Authn Context",
"SAML_Custom_Cert": "Custom Certificate",
"SAML_Custom_Debug": "Enable Debug",
"SAML_Custom_Entry_point": "Custom Entry Point",
Expand Down