passport-cortex
Version:
PassportJS authentication for Palo Alto Networks Cortex
81 lines (69 loc) • 3.42 kB
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var passportOauth2 = require('passport-oauth2');
require('passport');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
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);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
var CortexStrategy = /** @class */ (function (_super) {
__extends(CortexStrategy, _super);
function CortexStrategy(options, verify) {
var _this = this;
options = options || {};
var instanceId = options.instanceId, restOfOptions = __rest(options, ["instanceId"]);
_this = _super.call(this, __assign({ authorizationURL: 'https://identity.paloaltonetworks.com/as/authorization.oauth2', tokenURL: 'https://api.paloaltonetworks.com/api/oauth2/RequestToken' }, restOfOptions), verify) || this;
_this.name = 'cortex';
_this._instanceId = instanceId;
return _this;
}
CortexStrategy.prototype.authorizationParams = function (options) {
if (!this._instanceId && !options.instanceId) {
throw new Error('You must supply an instanceId to either the authentication function or the strategy constructor');
}
return { instance_id: options.instanceId || this._instanceId };
};
return CortexStrategy;
}(passportOauth2.Strategy));
exports.CortexStrategy = CortexStrategy;
;