Skip to content

Commit 264e1ca

Browse files
committed
fix(examples): remove incorrect POST binding query string example
SAMLResponse= in a query string implies HTTP-Redirect binding (DEFLATE compressed). A POST binding SAMLResponse lives in the HTTP POST body — it only looks like a query string when intercepted. Removed the misleadingly labelled example and the encodePostBinding helper it depended on.
1 parent d6711de commit 264e1ca

2 files changed

Lines changed: 0 additions & 22 deletions

File tree

src/lib/examples.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ describe('EXAMPLES', () => {
104104
expect(decodeSaml(url!.payload()).summary.binding).toBe('redirect');
105105
});
106106

107-
it('POST binding example uses post binding', () => {
108-
const post = EXAMPLES.find(
109-
(e) => e.category === 'Query string' && e.label.includes('POST')
110-
);
111-
expect(post).toBeDefined();
112-
expect(decodeSaml(post!.payload()).summary.binding).toBe('post');
113-
});
114-
115107
it('MFA SAMLResponse has REFEDS MFA authn context', () => {
116108
const mfa = EXAMPLES.find(
117109
(e) => e.category === 'SAMLResponse' && e.label.includes('MFA')

src/lib/examples.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ function encodeRedirectBinding(xml: string): string {
3737
return encodeURIComponent(btoa(binary));
3838
}
3939

40-
function encodePostBinding(xml: string): string {
41-
const bytes = new TextEncoder().encode(xml);
42-
let binary = '';
43-
for (let i = 0; i < bytes.length; i++) {
44-
binary += String.fromCharCode(bytes[i]);
45-
}
46-
return btoa(binary);
47-
}
48-
4940
function b64url(obj: object): string {
5041
return btoa(JSON.stringify(obj))
5142
.replace(/=/g, '')
@@ -229,11 +220,6 @@ export const EXAMPLES: Example[] = [
229220
payload: () =>
230221
`SAMLRequest=${encodeRedirectBinding(samlRequest())}&RelayState=%2Fdashboard`,
231222
},
232-
{
233-
label: 'POST binding form value',
234-
category: 'Query string',
235-
payload: () => `SAMLResponse=${encodeURIComponent(encodePostBinding(samlResponse()))}`,
236-
},
237223
{
238224
label: 'IdP redirect binding URL',
239225
category: 'Full URL',

0 commit comments

Comments
 (0)