-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for service provider transformation algorithms in asserti…
…on signature creation (#253)
- Loading branch information
1 parent
32948df
commit 7d1b6f0
Showing
4 changed files
with
40 additions
and
0 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
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 |
---|---|---|
|
@@ -265,6 +265,34 @@ test('send response with signed assertion and parse it', async t => { | |
t.is(extract.response.inResponseTo, 'request_id'); | ||
}); | ||
|
||
test('send response with signed assertion + custom transformation algorithms and parse it', async t => { | ||
// sender (caution: only use metadata and public key when declare pair-up in oppoent entity) | ||
const signedAssertionSp = serviceProvider( | ||
{ | ||
...defaultSpConfig, | ||
transformationAlgorithms: [ | ||
'http://www.w3.org/2000/09/xmldsig#enveloped-signature', | ||
'http://www.w3.org/2001/10/xml-exc-c14n#' | ||
] | ||
} | ||
); | ||
|
||
const user = { email: '[email protected]' }; | ||
const { id, context: SAMLResponse } = await idpNoEncrypt.createLoginResponse(signedAssertionSp, sampleRequestInfo, 'post', user, createTemplateCallback(idpNoEncrypt, sp, user)); | ||
// receiver (caution: only use metadata and public key when declare pair-up in oppoent entity) | ||
const { samlContent, extract } = await sp.parseLoginResponse(idpNoEncrypt, 'post', { body: { SAMLResponse } }); | ||
t.is(typeof id, 'string'); | ||
t.is(samlContent.startsWith('<samlp:Response'), true); | ||
t.is(samlContent.endsWith('/samlp:Response>'), true); | ||
t.is(extract.nameID, '[email protected]'); | ||
t.is(extract.response.inResponseTo, 'request_id'); | ||
|
||
// Verify xmldsig#enveloped-signature is included in the response | ||
if (samlContent.indexOf('http://www.w3.org/2000/09/xmldsig#enveloped-signature') === -1) { | ||
t.fail(); | ||
} | ||
}); | ||
|
||
test('send response with [custom template] signed assertion and parse it', async t => { | ||
// sender (caution: only use metadata and public key when declare pair-up in oppoent entity) | ||
const requestInfo = { extract: { request: { id: 'request_id' } } }; | ||
|