-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract sessionIndex from LogoutRequest (#501)
- Loading branch information
Showing
2 changed files
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -973,7 +973,7 @@ test('send login response with [custom template] encrypted signed assertion + si | |
|
||
// simulate idp-init slo | ||
test('idp sends a redirect logout request without signature and sp parses it', async t => { | ||
const { id, context } = idp.createLogoutRequest(sp, 'redirect', { logoutNameID: '[email protected]' }); | ||
const { id, context } = idp.createLogoutRequest(sp, 'redirect', { logoutNameID: '[email protected]', sessionIndex: '_664ade6a050f55a2c7cb2fb0571df7280365c0c7' }); | ||
const query = url.parse(context).query; | ||
t.is(query!.includes('SAMLRequest='), true); | ||
t.is(typeof id, 'string'); | ||
|
@@ -985,14 +985,15 @@ test('idp sends a redirect logout request without signature and sp parses it', a | |
t.is(result.sigAlg, null); | ||
t.is(typeof samlContent, 'string'); | ||
t.is(extract.nameID, '[email protected]'); | ||
t.is(extract.sessionIndex, '_664ade6a050f55a2c7cb2fb0571df7280365c0c7') | ||
t.is(extract.signature, null); | ||
t.is(typeof extract.request.id, 'string'); | ||
t.is(extract.request.destination, 'https://sp.example.org/sp/slo'); | ||
t.is(extract.issuer, 'https://idp.example.com/metadata'); | ||
}); | ||
|
||
test('idp sends a redirect logout request with signature and sp parses it', async t => { | ||
const { id, context } = idp.createLogoutRequest(spWantLogoutReqSign, 'redirect', { logoutNameID: '[email protected]' }); | ||
const { id, context } = idp.createLogoutRequest(spWantLogoutReqSign, 'redirect', { logoutNameID: '[email protected]', sessionIndex: '_664ade6a050f55a2c7cb2fb0571df7280365c0c7' }); | ||
const query = url.parse(context).query; | ||
t.is(query!.includes('SAMLRequest='), true); | ||
t.is(query!.includes('SigAlg='), true); | ||
|
@@ -1007,34 +1008,37 @@ test('idp sends a redirect logout request with signature and sp parses it', asyn | |
const octetString = Object.keys(originalURL.query).map(q => q + '=' + encodeURIComponent(originalURL.query[q] as string)).join('&'); | ||
const { extract } = await spWantLogoutReqSign.parseLogoutRequest(idp, 'redirect', { query: { SAMLRequest, Signature, SigAlg }, octetString}); | ||
t.is(extract.nameID, '[email protected]'); | ||
t.is(extract.sessionIndex, '_664ade6a050f55a2c7cb2fb0571df7280365c0c7') | ||
t.is(extract.issuer, 'https://idp.example.com/metadata'); | ||
t.is(typeof extract.request.id, 'string'); | ||
t.is(extract.request.destination, 'https://sp.example.org/sp/slo'); | ||
t.is(extract.signature, null); // redirect binding doesn't embed the signature | ||
}); | ||
|
||
test('idp sends a post logout request without signature and sp parses it', async t => { | ||
const { relayState, type, entityEndpoint, id, context } = idp.createLogoutRequest(sp, 'post', { logoutNameID: '[email protected]' }) as PostBindingContext; | ||
const { relayState, type, entityEndpoint, id, context } = idp.createLogoutRequest(sp, 'post', { logoutNameID: '[email protected]', sessionIndex: '_664ade6a050f55a2c7cb2fb0571df7280365c0c7' }) as PostBindingContext; | ||
t.is(typeof id, 'string'); | ||
t.is(typeof context, 'string'); | ||
t.is(typeof entityEndpoint, 'string'); | ||
t.is(type, 'SAMLRequest'); | ||
const { extract } = await sp.parseLogoutRequest(idp, 'post', { body: { SAMLRequest: context } }); | ||
t.is(extract.nameID, '[email protected]'); | ||
t.is(extract.sessionIndex, '_664ade6a050f55a2c7cb2fb0571df7280365c0c7') | ||
t.is(extract.issuer, 'https://idp.example.com/metadata'); | ||
t.is(typeof extract.request.id, 'string'); | ||
t.is(extract.request.destination, 'https://sp.example.org/sp/slo'); | ||
t.is(extract.signature, null); | ||
}); | ||
|
||
test('idp sends a post logout request with signature and sp parses it', async t => { | ||
const { relayState, type, entityEndpoint, id, context } = idp.createLogoutRequest(spWantLogoutReqSign, 'post', { logoutNameID: '[email protected]' }) as PostBindingContext; | ||
const { relayState, type, entityEndpoint, id, context } = idp.createLogoutRequest(spWantLogoutReqSign, 'post', { logoutNameID: '[email protected]', sessionIndex: '_664ade6a050f55a2c7cb2fb0571df7280365c0c7' }) as PostBindingContext; | ||
t.is(typeof id, 'string'); | ||
t.is(typeof context, 'string'); | ||
t.is(typeof entityEndpoint, 'string'); | ||
t.is(type, 'SAMLRequest'); | ||
const { extract } = await spWantLogoutReqSign.parseLogoutRequest(idp, 'post', { body: { SAMLRequest: context } }); | ||
t.is(extract.nameID, '[email protected]'); | ||
t.is(extract.sessionIndex, '_664ade6a050f55a2c7cb2fb0571df7280365c0c7') | ||
t.is(extract.issuer, 'https://idp.example.com/metadata'); | ||
t.is(extract.request.destination, 'https://sp.example.org/sp/slo'); | ||
t.is(typeof extract.request.id, 'string'); | ||
|