@boxyhq/saml-jackson 0.3.6-beta.592 → 0.3.6-beta.604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ export declare class OAuthController implements IOAuthController {
14
14
  });
15
15
  authorize(body: OAuthReqBody): Promise<{
16
16
  redirect_url: string;
17
+ authorize_form: string;
17
18
  }>;
18
19
  samlResponse(body: SAMLResponsePayload): Promise<{
19
20
  redirect_url: string;
@@ -40,9 +40,6 @@ const allowed = __importStar(require("./oauth/allowed"));
40
40
  const codeVerifier = __importStar(require("./oauth/code-verifier"));
41
41
  const redirect = __importStar(require("./oauth/redirect"));
42
42
  const utils_1 = require("./utils");
43
- const util_1 = require("util");
44
- const zlib_1 = require("zlib");
45
- const deflateRawAsync = (0, util_1.promisify)(zlib_1.deflateRaw);
46
43
  const relayStatePrefix = 'boxyhq_jackson_';
47
44
  function getEncodedClientId(client_id) {
48
45
  try {
@@ -133,13 +130,26 @@ class OAuthController {
133
130
  code_challenge,
134
131
  code_challenge_method,
135
132
  });
136
- // deepak: When supporting HTTP-POST skip deflate
137
- const samlReqEnc = yield deflateRawAsync(samlReq.request);
138
- const redirectUrl = redirect.success(samlConfig.idpMetadata.sso.redirectUrl, {
139
- RelayState: relayStatePrefix + sessionId,
140
- SAMLRequest: Buffer.from(samlReqEnc).toString('base64'),
141
- });
142
- return { redirect_url: redirectUrl };
133
+ const relayState = relayStatePrefix + sessionId;
134
+ const samlReqEnc = Buffer.from(samlReq.request).toString('base64');
135
+ const { sso } = samlConfig.idpMetadata;
136
+ let redirectUrl = '';
137
+ let authorizeForm = '';
138
+ // HTTP redirect binding
139
+ if ('redirectUrl' in sso) {
140
+ redirectUrl = redirect.success(sso.redirectUrl, {
141
+ RelayState: relayState,
142
+ SAMLRequest: samlReqEnc,
143
+ });
144
+ }
145
+ // HTTP POST binding
146
+ if ('postUrl' in sso) {
147
+ authorizeForm = (0, utils_1.createAuthorizeForm)(relayState, samlReqEnc, sso.postUrl);
148
+ }
149
+ return {
150
+ redirect_url: redirectUrl,
151
+ authorize_form: authorizeForm,
152
+ };
143
153
  });
144
154
  }
145
155
  samlResponse(body) {
@@ -2,3 +2,4 @@ export declare enum IndexNames {
2
2
  EntityID = "entityID",
3
3
  TenantProduct = "tenantProduct"
4
4
  }
5
+ export declare const createAuthorizeForm: (relayState: string, samlReqEnc: string, postUrl: string) => string;
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IndexNames = void 0;
3
+ exports.createAuthorizeForm = exports.IndexNames = void 0;
4
4
  var IndexNames;
5
5
  (function (IndexNames) {
6
6
  IndexNames["EntityID"] = "entityID";
7
7
  IndexNames["TenantProduct"] = "tenantProduct";
8
8
  })(IndexNames = exports.IndexNames || (exports.IndexNames = {}));
9
+ const createAuthorizeForm = (relayState, samlReqEnc, postUrl) => {
10
+ const formElements = [
11
+ '<!DOCTYPE html>',
12
+ '<html>',
13
+ '<head>',
14
+ '<meta charset="utf-8">',
15
+ '<meta http-equiv="x-ua-compatible" content="ie=edge">',
16
+ '</head>',
17
+ '<body onload="document.forms[0].submit()">',
18
+ '<noscript>',
19
+ '<p>Note: Since your browser does not support JavaScript, you must press the Continue button once to proceed.</p>',
20
+ '</noscript>',
21
+ '<form method="post" action="' + encodeURI(postUrl) + '">',
22
+ '<input type="hidden" name="RelayState" value="' + relayState + '"/>',
23
+ '<input type="hidden" name="SAMLRequest" value="' + samlReqEnc + '"/>',
24
+ '<input type="submit" value="Continue" />',
25
+ '</form>',
26
+ '<script>document.forms[0].style.display="none";</script>',
27
+ '</body>',
28
+ '</html>',
29
+ ];
30
+ return formElements.join('');
31
+ };
32
+ exports.createAuthorizeForm = createAuthorizeForm;
package/dist/saml/saml.js CHANGED
@@ -68,7 +68,7 @@ const request = ({ ssoUrl, entityID, callbackUrl, isPassive = false, forceAuthn
68
68
  '@ID': id,
69
69
  '@Version': '2.0',
70
70
  '@IssueInstant': date,
71
- '@ProtocolBinding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
71
+ '@ProtocolBinding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
72
72
  '@Destination': ssoUrl,
73
73
  'saml:Issuer': {
74
74
  '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
package/dist/typings.d.ts CHANGED
@@ -28,6 +28,7 @@ export interface IAPIController {
28
28
  export interface IOAuthController {
29
29
  authorize(body: OAuthReqBody): Promise<{
30
30
  redirect_url: string;
31
+ authorize_form: string;
31
32
  }>;
32
33
  samlResponse(body: SAMLResponsePayload): Promise<{
33
34
  redirect_url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxyhq/saml-jackson",
3
- "version": "0.3.6-beta.592",
3
+ "version": "0.3.6-beta.604",
4
4
  "description": "SAML 2.0 service",
5
5
  "keywords": [
6
6
  "SAML 2.0"
@@ -34,8 +34,6 @@
34
34
  "@boxyhq/saml20": "0.2.0",
35
35
  "@peculiar/webcrypto": "1.2.3",
36
36
  "@peculiar/x509": "1.6.1",
37
- "cors": "2.8.5",
38
- "express": "4.17.2",
39
37
  "mongodb": "4.3.0",
40
38
  "mysql2": "2.3.3",
41
39
  "pg": "8.7.1",