openam-agent-custom
Version:
Customized ForgeRock AM Policy Agent for Node.js from Zoltan Tarcsay
62 lines • 2.5 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = require("axios");
var url = require("url");
var am_client_1 = require("./am-client");
var MtsAmClient = /** @class */ (function (_super) {
__extends(MtsAmClient, _super);
function MtsAmClient() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Gets a user's profile.
* Customized to supported API.
*/
MtsAmClient.prototype.getProfile = function (userId, realm, sessionId, cookieName) {
var _a;
if (realm === void 0) { realm = 'root'; }
// var cookieName = cookieName;
return axios_1.default
.get(this.serverAddress + "/json/" + realm + "/users/" + userId, {
headers: (_a = {
'Accept-API-Version': 'resource=3.0,protocol=1.0',
'Content-Type': 'application/json',
Host: this.hostname
},
_a[cookieName] = sessionId,
_a)
})
.then(function (res) { return res.data; });
};
/**
* Returns an OpenAM login URL with the goto query parameter set to the original URL in req.
* Customized to accept service parameter, realm param unused.
*/
MtsAmClient.prototype.getLoginUrl = function (goto, realm) {
if (realm === void 0) { realm = '/'; }
// FIXME hardcoded force HTTPS
goto = goto.replace('http://', 'https://');
var httpsServerUrl = this.serverUrl.replace('http://', 'https://');
return httpsServerUrl + url.format({
pathname: '/UI/Login',
// FIXME hardcoded service
query: { goto: goto, 'realm': '/users', 'service': 'login' }
});
};
return MtsAmClient;
}(am_client_1.AmClient));
exports.MtsAmClient = MtsAmClient;
//# sourceMappingURL=mts-am-client.js.map