Skip to content

Commit 8114d4c

Browse files
authored
Add deprecation notices for renamed variables (#568)
* Deprecate RACComparison in favor of racComparison * Deprecate disableRequestACSUrl in favor of disableRequestAcsUrl
1 parent 0804cc4 commit 8114d4c

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ type Profile = {
127127
* `attributeConsumingServiceIndex`: optional `AttributeConsumingServiceIndex` attribute to add to AuthnRequest to instruct the IDP which attribute set to attach to the response ([link](http://blog.aniljohn.com/2014/01/data-minimization-front-channel-saml-attribute-requests.html))
128128
* `disableRequestedAuthnContext`: if truthy, do not request a specific authentication context. This is [known to help when authenticating against Active Directory](https://github.com/node-saml/passport-saml/issues/226) (AD FS) servers.
129129
* `authnContext`: if truthy, name identifier format to request auth context (default: `urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport`); array of values is also supported
130-
* `RACComparison`: Requested Authentication Context comparison type. Possible values are 'exact','minimum','maximum','better'. Default is 'exact'.
130+
* `racComparison`: Requested Authentication Context comparison type. Possible values are 'exact','minimum','maximum','better'. Default is 'exact'.
131131

132132
* `forceAuthn`: if set to true, the initial SAML request from the service provider specifies that the IdP should force re-authentication of the user, even if they possess a valid session.
133133
* `providerName`: optional human-readable name of the requester for use by the presenter's user agent or the identity provider
134134
* `skipRequestCompression`: if set to true, the SAML request from the service provider won't be compressed.
135135
* `authnRequestBinding`: if set to `HTTP-POST`, will request authentication from IDP via HTTP POST binding, otherwise defaults to HTTP Redirect
136-
* `disableRequestACSUrl`: if truthy, SAML AuthnRequest from the service provider will not include the optional AssertionConsumerServiceURL. Default is falsy so it is automatically included.
136+
* `disableRequestAcsUrl`: if truthy, SAML AuthnRequest from the service provider will not include the optional AssertionConsumerServiceURL. Default is falsy so it is automatically included.
137137
* `scoping`: An optional configuration which implements the functionality [explained in the SAML spec paragraph "3.4.1.2 Element <Scoping>"](https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf). The config object is structured as following:
138138
```javascript
139139
{

docs/adfs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ passport.use(new SamlStrategy(
5757
identifierFormat: null,
5858
// this is configured under the Advanced tab in AD FS relying party
5959
signatureAlgorithm: 'sha256',
60-
RACComparison: 'exact', // default to exact RequestedAuthnContext Comparison Type
60+
racComparison: 'exact', // default to exact RequestedAuthnContext Comparison Type
6161
},
6262
function(profile, done) {
6363
return done(null,

src/passport-saml/saml.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,27 @@ class SAML {
117117
if (options.privateCert) {
118118
console.warn("options.privateCert has been deprecated; use options.privateKey instead.");
119119

120-
if (!options.privateKey) {
120+
if (options.privateKey == null) {
121121
options.privateKey = options.privateCert;
122122
}
123123
}
124124

125+
if (options.RACComparison) {
126+
console.warn("options.RACComparison has been deprecated; use options.racComparison instead.")
127+
128+
if (options.racComparison == null) {
129+
options.racComparison = options.RACComparison;
130+
}
131+
}
132+
133+
if (options.disableRequestACSUrl) {
134+
console.warn("options.disableRequestACSUrl has been deprecated; use options.disableRequestAcsUrl instead.")
135+
136+
if (options.disableRequestAcsUrl == null) {
137+
options.disableRequestAcsUrl = options.disableRequestACSUrl;
138+
}
139+
}
140+
125141
if (Object.prototype.hasOwnProperty.call(options, 'cert') && !options.cert) {
126142
throw new Error('Invalid property: cert must not be empty');
127143
}
@@ -185,8 +201,8 @@ class SAML {
185201
* - maximum: Assertion context must be no stronger than a context in the list
186202
* - better: Assertion context must be stronger than all contexts in the list
187203
*/
188-
if (!options.RACComparison || ['exact','minimum','maximum','better'].indexOf(options.RACComparison) === -1){
189-
options.RACComparison = 'exact';
204+
if (!options.racComparison || ['exact','minimum','maximum','better'].indexOf(options.racComparison) === -1){
205+
options.racComparison = 'exact';
190206
}
191207

192208
return options as SAMLOptions;
@@ -274,7 +290,7 @@ class SAML {
274290
request['samlp:AuthnRequest']['@ForceAuthn'] = true;
275291
}
276292

277-
if (!this.options.disableRequestACSUrl) {
293+
if (!this.options.disableRequestAcsUrl) {
278294
request['samlp:AuthnRequest']['@AssertionConsumerServiceURL'] = this.getCallbackUrl(req);
279295
}
280296

@@ -297,7 +313,7 @@ class SAML {
297313

298314
request['samlp:AuthnRequest']['samlp:RequestedAuthnContext'] = {
299315
'@xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
300-
'@Comparison': this.options.RACComparison,
316+
'@Comparison': this.options.racComparison,
301317
'saml:AuthnContextClassRef': authnContextClassRefs
302318
};
303319
}

src/passport-saml/types.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export interface SAMLOptions {
3737
authnContext: string | string[];
3838
forceAuthn: boolean;
3939
skipRequestCompression: boolean;
40-
RACComparison: 'exact' | 'minimum' | 'maximum' | 'better';
40+
/** @deprecated use racComparison field instead */
41+
RACComparison?: 'exact' | 'minimum' | 'maximum' | 'better';
42+
racComparison: 'exact' | 'minimum' | 'maximum' | 'better';
4143
providerName: string;
4244
passive: boolean;
4345
idpIssuer: string;
@@ -57,7 +59,9 @@ export interface SAMLOptions {
5759
// extras
5860
xmlSignatureTransforms: string[];
5961
digestAlgorithm: string;
60-
disableRequestACSUrl: boolean;
62+
/** @deprecated use disableRequestAcsUrl field instead */
63+
disableRequestACSUrl?: boolean;
64+
disableRequestAcsUrl: boolean;
6165
}
6266

6367
export type SamlConfig = Partial<SAMLOptions> & StrategyOptions

test/tests.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ describe( 'passport-saml /', function() {
512512
config: {
513513
identifierFormat: null,
514514
disableRequestedAuthnContext: true,
515-
disableRequestACSUrl: true,
515+
disableRequestAcsUrl: true,
516516
},
517517
result: {
518518
'samlp:AuthnRequest':
@@ -2247,14 +2247,14 @@ describe( 'passport-saml /', function() {
22472247
additionalLogoutParams.should.containEql({'queryParam': 'queryParamRuntimeValue'});
22482248
});
22492249

2250-
it('should check the value of the option `RACComparison`', function() {
2251-
var samlObjBadComparisonType = new SAML({ RACComparison: 'bad_value' });
2252-
should.equal(samlObjBadComparisonType.options.RACComparison, 'exact', ['the default value of the option `RACComparison` must be exact']);
2250+
it('should check the value of the option `racComparison`', function() {
2251+
var samlObjBadComparisonType = new SAML({ racComparison: 'bad_value' });
2252+
should.equal(samlObjBadComparisonType.options.racComparison, 'exact', ['the default value of the option `racComparison` must be exact']);
22532253

22542254
var validComparisonTypes = ['exact','minimum','maximum','better'], samlObjValidComparisonType;
2255-
validComparisonTypes.forEach(function(RACComparison) {
2256-
samlObjValidComparisonType = new SAML( {RACComparison: RACComparison} );
2257-
should.equal(samlObjValidComparisonType.options.RACComparison, RACComparison);
2255+
validComparisonTypes.forEach(function(racComparison) {
2256+
samlObjValidComparisonType = new SAML( {racComparison: racComparison} );
2257+
should.equal(samlObjValidComparisonType.options.racComparison, racComparison);
22582258
});
22592259
});
22602260
});

0 commit comments

Comments
 (0)