@boxyhq/saml-jackson 0.1.5-beta.112 → 0.1.5-beta.114
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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/controller/oauth.js +12 -2
- package/src/controller/utils.js +0 -11
- package/src/env.js +0 -3
- package/src/jackson.js +0 -11
package/README.md
CHANGED
package/package.json
CHANGED
package/src/controller/oauth.js
CHANGED
@@ -2,7 +2,7 @@ const crypto = require('crypto');
|
|
2
2
|
|
3
3
|
const saml = require('../saml/saml.js');
|
4
4
|
const codeVerifier = require('./oauth/code-verifier.js');
|
5
|
-
const { indexNames
|
5
|
+
const { indexNames } = require('./utils.js');
|
6
6
|
const dbutils = require('../db/utils.js');
|
7
7
|
const redirect = require('./oauth/redirect.js');
|
8
8
|
const allowed = require('./oauth/allowed.js');
|
@@ -15,6 +15,16 @@ let options;
|
|
15
15
|
|
16
16
|
const relayStatePrefix = 'boxyhq_jackson_';
|
17
17
|
|
18
|
+
const extractBearerToken = (req) => {
|
19
|
+
const authHeader = req.get('authorization');
|
20
|
+
const parts = (authHeader || '').split(' ');
|
21
|
+
if (parts.length > 1) {
|
22
|
+
return parts[1];
|
23
|
+
}
|
24
|
+
|
25
|
+
return null;
|
26
|
+
};
|
27
|
+
|
18
28
|
function getEncodedClientId(client_id) {
|
19
29
|
try {
|
20
30
|
const sp = new URLSearchParams(client_id);
|
@@ -293,7 +303,7 @@ const token = async (req, res) => {
|
|
293
303
|
};
|
294
304
|
|
295
305
|
const userInfo = async (req, res) => {
|
296
|
-
let token =
|
306
|
+
let token = extractBearerToken(req);
|
297
307
|
|
298
308
|
// check for query param
|
299
309
|
if (!token) {
|
package/src/controller/utils.js
CHANGED
@@ -3,17 +3,6 @@ const indexNames = {
|
|
3
3
|
tenantProduct: 'tenantProduct',
|
4
4
|
};
|
5
5
|
|
6
|
-
const extractAuthToken = (req) => {
|
7
|
-
const authHeader = req.get('authorization');
|
8
|
-
const parts = (authHeader || '').split(' ');
|
9
|
-
if (parts.length > 1) {
|
10
|
-
return parts[1];
|
11
|
-
}
|
12
|
-
|
13
|
-
return null;
|
14
|
-
};
|
15
|
-
|
16
6
|
module.exports = {
|
17
7
|
indexNames,
|
18
|
-
extractAuthToken,
|
19
8
|
};
|
package/src/env.js
CHANGED
@@ -7,8 +7,6 @@ const samlPath = process.env.SAML_PATH || '/oauth/saml';
|
|
7
7
|
const internalHostUrl = process.env.INTERNAL_HOST_URL || 'localhost';
|
8
8
|
const internalHostPort = (process.env.INTERNAL_HOST_PORT || '6000') * 1;
|
9
9
|
|
10
|
-
const apiKeys = (process.env.JACKSON_API_KEYS || '').split(',');
|
11
|
-
|
12
10
|
const samlAudience = process.env.SAML_AUDIENCE;
|
13
11
|
const preLoadedConfig = process.env.PRE_LOADED_CONFIG;
|
14
12
|
|
@@ -29,7 +27,6 @@ module.exports = {
|
|
29
27
|
preLoadedConfig,
|
30
28
|
internalHostUrl,
|
31
29
|
internalHostPort,
|
32
|
-
apiKeys,
|
33
30
|
idpEnabled,
|
34
31
|
db,
|
35
32
|
useInternalServer: !(
|
package/src/jackson.js
CHANGED
@@ -2,7 +2,6 @@ const express = require('express');
|
|
2
2
|
const cors = require('cors');
|
3
3
|
|
4
4
|
const env = require('./env.js');
|
5
|
-
const { extractAuthToken } = require('./controller/utils.js');
|
6
5
|
|
7
6
|
let apiController;
|
8
7
|
let oauthController;
|
@@ -67,18 +66,8 @@ if (env.useInternalServer) {
|
|
67
66
|
internalApp.use(express.urlencoded({ extended: true }));
|
68
67
|
}
|
69
68
|
|
70
|
-
const validateApiKey = (token) => {
|
71
|
-
return env.apiKeys.includes(token);
|
72
|
-
};
|
73
|
-
|
74
69
|
internalApp.post(apiPath + '/config', async (req, res) => {
|
75
70
|
try {
|
76
|
-
const apiKey = extractAuthToken(req);
|
77
|
-
if (!validateApiKey(apiKey)) {
|
78
|
-
res.status(401).send('Unauthorized');
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
|
82
71
|
res.json(await apiController.config(req.body));
|
83
72
|
} catch (err) {
|
84
73
|
res.status(500).json({
|