-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.auth.js
More file actions
36 lines (30 loc) · 1.06 KB
/
app.auth.js
File metadata and controls
36 lines (30 loc) · 1.06 KB
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
/*
* @forgerock/javascript-sdk
*
* app.auth.js
*
* Copyright (c) 2020 - 2025 Ping Identity Corporation. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import request from 'superagent';
import { AM_URL, REALM_PATH } from './env.config.js';
export let session;
export async function authorizeApp({ un, pw }) {
try {
const response = await request
.post(`${AM_URL}/json/realms/${REALM_PATH}/authenticate`)
.set('Content-Type', 'application/json')
.set('Accept-API-Version', 'resource=2.0, protocol=1.0')
.set('X-OpenAM-Username', un)
.set('X-OpenAM-Password', pw)
.send({});
session = response.body;
console.log(`REST app identity token: ${session.tokenId}`);
return session;
} catch (error) {
console.warn('\n###################################################');
console.warn('WARNING: REST app user for Step Up/Txn Auth missing');
console.warn('###################################################\n');
}
}