-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebHookHandlers.js
51 lines (45 loc) · 1.24 KB
/
webHookHandlers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import config from './config.js';
import utils from './utils.js';
const webHookHandlers = {
tokenHandler: function (req, res) {
console.log("webHookHandlers.tokenHandler()");
let auth = req.get('Authorization');
let results = {}
console.log("auth: " + auth + " config.OKTA_HOOK_AUTH: " + config.OKTA_HOOK_AUTH);
if(auth == config.OKTA_HOOK_AUTH) {
results = {
"commands": [
{
"type": "com.okta.identity.patch",
"value": [
{
"op": "add",
"path": "/claims/account_number",
"value": "F0" + utils.between(1000, 9999) + "-" + utils.between(1000, 9999)
}
]
},
{
"type": "com.okta.access.patch",
"value": [
{
"op": "add",
"path": "/claims/access",
"value": "GRANTED"
}
]
}
]
};
} else {
results = {
"success": false,
"message": "Requires Auth to call this hook."
}
res.status(403);
}
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(results));
}
};
export default webHookHandlers;