@p0security/cli 0.18.8 → 0.18.10
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/build/dist/commands/__tests__/login.test.js +17 -10
- package/build/dist/commands/__tests__/login.test.js.map +1 -1
- package/build/dist/commands/__tests__/request.test.js +64 -9
- package/build/dist/commands/__tests__/request.test.js.map +1 -1
- package/build/dist/commands/__tests__/ssh.test.js +75 -51
- package/build/dist/commands/__tests__/ssh.test.js.map +1 -1
- package/build/dist/commands/allow.js +3 -2
- package/build/dist/commands/allow.js.map +1 -1
- package/build/dist/commands/aws/__tests__/role.test.js +18 -12
- package/build/dist/commands/aws/__tests__/role.test.js.map +1 -1
- package/build/dist/commands/aws/index.js +0 -4
- package/build/dist/commands/aws/index.js.map +1 -1
- package/build/dist/commands/aws/permission-set.js +1 -2
- package/build/dist/commands/aws/permission-set.js.map +1 -1
- package/build/dist/commands/aws/role.js +1 -2
- package/build/dist/commands/aws/role.js.map +1 -1
- package/build/dist/commands/grant.js +12 -2
- package/build/dist/commands/grant.js.map +1 -1
- package/build/dist/commands/index.js +2 -0
- package/build/dist/commands/index.js.map +1 -1
- package/build/dist/commands/kubeconfig.js +1 -2
- package/build/dist/commands/kubeconfig.js.map +1 -1
- package/build/dist/commands/login.js +19 -27
- package/build/dist/commands/login.js.map +1 -1
- package/build/dist/commands/logout.d.ts +2 -0
- package/build/dist/commands/logout.js +61 -0
- package/build/dist/commands/logout.js.map +1 -0
- package/build/dist/commands/ls.js +1 -2
- package/build/dist/commands/ls.js.map +1 -1
- package/build/dist/commands/request.js +12 -2
- package/build/dist/commands/request.js.map +1 -1
- package/build/dist/commands/scp.js +1 -2
- package/build/dist/commands/scp.js.map +1 -1
- package/build/dist/commands/shared/index.d.ts +7 -4
- package/build/dist/commands/shared/index.js +20 -45
- package/build/dist/commands/shared/index.js.map +1 -1
- package/build/dist/commands/shared/request.d.ts +3 -0
- package/build/dist/commands/shared/request.js +105 -59
- package/build/dist/commands/shared/request.js.map +1 -1
- package/build/dist/commands/shared/ssh.js +21 -12
- package/build/dist/commands/shared/ssh.js.map +1 -1
- package/build/dist/commands/ssh-proxy.js +2 -3
- package/build/dist/commands/ssh-proxy.js.map +1 -1
- package/build/dist/commands/ssh-resolve.js +2 -3
- package/build/dist/commands/ssh-resolve.js.map +1 -1
- package/build/dist/commands/ssh.js +3 -4
- package/build/dist/commands/ssh.js.map +1 -1
- package/build/dist/drivers/__tests__/api.test.d.ts +1 -0
- package/build/dist/drivers/__tests__/api.test.js +688 -0
- package/build/dist/drivers/__tests__/api.test.js.map +1 -0
- package/build/dist/drivers/api.d.ts +17 -1
- package/build/dist/drivers/api.js +252 -25
- package/build/dist/drivers/api.js.map +1 -1
- package/build/dist/drivers/auth/index.js +23 -10
- package/build/dist/drivers/auth/index.js.map +1 -1
- package/build/dist/drivers/auth/path.d.ts +2 -0
- package/build/dist/drivers/auth/path.js +19 -1
- package/build/dist/drivers/auth/path.js.map +1 -1
- package/build/dist/drivers/config.js +10 -18
- package/build/dist/drivers/config.js.map +1 -1
- package/build/dist/drivers/env.d.ts +1 -1
- package/build/dist/drivers/env.js +2 -2
- package/build/dist/drivers/env.js.map +1 -1
- package/build/dist/drivers/firestore.d.ts +0 -10
- package/build/dist/drivers/firestore.js +3 -43
- package/build/dist/drivers/firestore.js.map +1 -1
- package/build/dist/drivers/org.d.ts +1 -0
- package/build/dist/drivers/org.js +43 -0
- package/build/dist/drivers/org.js.map +1 -0
- package/build/dist/plugins/aws/config.js +3 -6
- package/build/dist/plugins/aws/config.js.map +1 -1
- package/build/dist/plugins/azure/login.d.ts +3 -0
- package/build/dist/plugins/azure/login.js +86 -0
- package/build/dist/plugins/azure/login.js.map +1 -0
- package/build/dist/plugins/google/ssh-key.js +9 -9
- package/build/dist/plugins/google/ssh-key.js.map +1 -1
- package/build/dist/plugins/kubeconfig/index.js +12 -10
- package/build/dist/plugins/kubeconfig/index.js.map +1 -1
- package/build/dist/plugins/login.js +11 -9
- package/build/dist/plugins/login.js.map +1 -1
- package/build/dist/plugins/self-hosted/ssh.d.ts +3 -0
- package/build/dist/plugins/self-hosted/ssh.js +80 -0
- package/build/dist/plugins/self-hosted/ssh.js.map +1 -0
- package/build/dist/plugins/self-hosted/types.d.ts +31 -0
- package/build/dist/plugins/self-hosted/types.js +3 -0
- package/build/dist/plugins/self-hosted/types.js.map +1 -0
- package/build/dist/types/identity.d.ts +2 -1
- package/build/dist/types/org.d.ts +2 -0
- package/build/dist/types/request.d.ts +1 -1
- package/build/dist/types/ssh.d.ts +5 -4
- package/build/dist/types/ssh.js +6 -1
- package/build/dist/types/ssh.js.map +1 -1
- package/build/dist/util.d.ts +3 -0
- package/build/dist/util.js +19 -3
- package/build/dist/util.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/p0 +0 -13
- package/package.json +2 -1
- package/build/dist/testing/firestore.d.ts +0 -2
- package/build/dist/testing/firestore.js +0 -17
- package/build/dist/testing/firestore.js.map +0 -1
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.defaultConfig = void 0;
|
|
8
8
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
9
|
dotenv_1.default.config();
|
|
10
10
|
const { env } = process;
|
|
11
|
-
exports.
|
|
11
|
+
exports.defaultConfig = {
|
|
12
12
|
fs: {
|
|
13
13
|
// Falls back to public production Firestore credentials
|
|
14
14
|
apiKey: (_a = env.P0_FS_API_KEY) !== null && _a !== void 0 ? _a : "AIzaSyCaL-Ik_l_5tdmgNUNZ4Nv6NuR4o5_PPfs",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/drivers/env.ts"],"names":[],"mappings":";;;;;;;AAWA,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAEX,QAAA,
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/drivers/env.ts"],"names":[],"mappings":";;;;;;;AAWA,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAEX,QAAA,aAAa,GAA4B;IACpD,EAAE,EAAE;QACF,wDAAwD;QACxD,MAAM,EAAE,MAAA,GAAG,CAAC,aAAa,mCAAI,yCAAyC;QACtE,UAAU,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,yBAAyB;QAC9D,SAAS,EAAE,MAAA,GAAG,CAAC,gBAAgB,mCAAI,SAAS;QAC5C,aAAa,EAAE,MAAA,GAAG,CAAC,oBAAoB,mCAAI,qBAAqB;QAChE,iBAAiB,EAAE,MAAA,GAAG,CAAC,yBAAyB,mCAAI,cAAc;QAClE,KAAK,EAAE,MAAA,GAAG,CAAC,YAAY,mCAAI,2CAA2C;KACvE;IACD,MAAM,EAAE;QACN,QAAQ,EACN,MAAA,GAAG,CAAC,wBAAwB,mCAC5B,0EAA0E;QAC5E,4EAA4E;QAC5E,qFAAqF;QACrF,kFAAkF;QAClF,2FAA2F;QAC3F,uHAAuH;QACvH,iFAAiF;QACjF,uEAAuE;QACvE,wFAAwF;QACxF,yBAAyB,EACvB,MAAA,GAAG,CAAC,4BAA4B,mCAAI,qCAAqC;KAC5E;IACD,MAAM,EAAE,MAAA,GAAG,CAAC,UAAU,mCAAI,oBAAoB;IAC9C,WAAW,EAAE,MAAA,GAAG,CAAC,MAAM,mCAAI,YAAY;IACvC,cAAc,EAAE,+CAA+C;IAC/D,WAAW,EAAE,wDAAwD;CACtE,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Identity } from "../types/identity";
|
|
2
2
|
import { OrgData } from "../types/org";
|
|
3
3
|
import { EmailAuthCredential, OAuthCredential, UserCredential } from "firebase/auth";
|
|
4
|
-
import { CollectionReference, DocumentReference } from "firebase/firestore";
|
|
5
4
|
export declare function initializeFirebase(): Promise<void>;
|
|
6
5
|
export declare const signInToTenant: (org: OrgData, firebaseCredential: EmailAuthCredential | OAuthCredential, options?: {
|
|
7
6
|
debug?: boolean;
|
|
@@ -9,12 +8,3 @@ export declare const signInToTenant: (org: OrgData, firebaseCredential: EmailAut
|
|
|
9
8
|
export declare const authenticateToFirebase: (identity: Identity, options?: {
|
|
10
9
|
debug?: boolean;
|
|
11
10
|
}) => Promise<UserCredential>;
|
|
12
|
-
export declare const collection: <T>(path: string, ...pathSegments: string[]) => CollectionReference<T, import("@firebase/firestore").DocumentData>;
|
|
13
|
-
export declare const doc: <T>(path: string) => DocumentReference<T, import("@firebase/firestore").DocumentData>;
|
|
14
|
-
export declare const bootstrapDoc: <T>(path: string) => DocumentReference<T, import("@firebase/firestore").DocumentData>;
|
|
15
|
-
/** Ensures that Firestore is shutdown at command termination
|
|
16
|
-
*
|
|
17
|
-
* This prevents Firestore from holding the command on execution completion or failure.
|
|
18
|
-
*/
|
|
19
|
-
export declare const fsShutdownGuard: <P, T>(cb: (args: P) => Promise<T>) => (args: P) => Promise<void>;
|
|
20
|
-
export declare const shutdownFirebase: () => void;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.authenticateToFirebase = exports.signInToTenant = exports.initializeFirebase = void 0;
|
|
13
13
|
/** Copyright © 2024-present P0 Security
|
|
14
14
|
|
|
15
15
|
This file is part of @p0security/cli
|
|
@@ -22,23 +22,15 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
22
22
|
**/
|
|
23
23
|
const login_1 = require("../plugins/email/login");
|
|
24
24
|
const config_1 = require("./config");
|
|
25
|
-
const env_1 = require("./env");
|
|
26
25
|
const stdio_1 = require("./stdio");
|
|
27
26
|
const util_1 = require("./util");
|
|
28
27
|
const app_1 = require("firebase/app");
|
|
29
28
|
const auth_1 = require("firebase/auth");
|
|
30
|
-
const firestore_1 = require("firebase/firestore");
|
|
31
|
-
const bootstrapApp = (0, app_1.initializeApp)(env_1.bootstrapConfig.fs, "bootstrapApp");
|
|
32
|
-
const bootstrapFirestore = (0, firestore_1.getFirestore)(bootstrapApp);
|
|
33
29
|
let app;
|
|
34
|
-
let firestore;
|
|
35
30
|
function initializeFirebase() {
|
|
36
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
app = (0, app_1.initializeApp)(tenantConfig.fs, "authFirebase");
|
|
40
|
-
firestore = (0, firestore_1.getFirestore)(app);
|
|
41
|
-
}
|
|
32
|
+
const tenantConfig = yield (0, config_1.loadConfig)();
|
|
33
|
+
app = (0, app_1.initializeApp)(tenantConfig.fs, "authFirebase");
|
|
42
34
|
});
|
|
43
35
|
}
|
|
44
36
|
exports.initializeFirebase = initializeFirebase;
|
|
@@ -102,36 +94,4 @@ const authenticateToFirebase = (identity, options) => __awaiter(void 0, void 0,
|
|
|
102
94
|
return yield (0, exports.signInToTenant)(org, firebaseCredential, options);
|
|
103
95
|
});
|
|
104
96
|
exports.authenticateToFirebase = authenticateToFirebase;
|
|
105
|
-
const collection = (path, ...pathSegments) => {
|
|
106
|
-
return (0, firestore_1.collection)(firestore, path, ...pathSegments);
|
|
107
|
-
};
|
|
108
|
-
exports.collection = collection;
|
|
109
|
-
const doc = (path) => {
|
|
110
|
-
return (0, firestore_1.doc)(firestore, path);
|
|
111
|
-
};
|
|
112
|
-
exports.doc = doc;
|
|
113
|
-
const bootstrapDoc = (path) => {
|
|
114
|
-
return (0, firestore_1.doc)(bootstrapFirestore, path);
|
|
115
|
-
};
|
|
116
|
-
exports.bootstrapDoc = bootstrapDoc;
|
|
117
|
-
/** Ensures that Firestore is shutdown at command termination
|
|
118
|
-
*
|
|
119
|
-
* This prevents Firestore from holding the command on execution completion or failure.
|
|
120
|
-
*/
|
|
121
|
-
const fsShutdownGuard = (cb) => (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
-
try {
|
|
123
|
-
yield cb(args);
|
|
124
|
-
}
|
|
125
|
-
finally {
|
|
126
|
-
(0, exports.shutdownFirebase)();
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
exports.fsShutdownGuard = fsShutdownGuard;
|
|
130
|
-
const shutdownFirebase = () => {
|
|
131
|
-
if (bootstrapFirestore)
|
|
132
|
-
void (0, firestore_1.terminate)(bootstrapFirestore);
|
|
133
|
-
if (firestore)
|
|
134
|
-
void (0, firestore_1.terminate)(firestore);
|
|
135
|
-
};
|
|
136
|
-
exports.shutdownFirebase = shutdownFirebase;
|
|
137
97
|
//# sourceMappingURL=firestore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestore.js","sourceRoot":"","sources":["../../../src/drivers/firestore.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,kDAA+D;AAG/D,qCAAyD;AACzD
|
|
1
|
+
{"version":3,"file":"firestore.js","sourceRoot":"","sources":["../../../src/drivers/firestore.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,kDAA+D;AAG/D,qCAAyD;AACzD,mCAAiC;AACjC,iCAAqD;AACrD,sCAAyE;AACzE,wCAQuB;AAEvB,IAAI,GAAgB,CAAC;AAErB,SAAsB,kBAAkB;;QACtC,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAU,GAAE,CAAC;QACxC,GAAG,GAAG,IAAA,mBAAa,EAAC,YAAY,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;CAAA;AAHD,gDAGC;AAED,MAAM,cAAc,GAAG,CAAC,GAAY,EAAE,E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IAAI,0CAAE,KAAK,CAAA,EAAE;QAChC,MAAM,4FAA4F,IAAA,0BAAiB,GAAE,EAAE,CAAC;KACzH;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAA,CAAC;AAxCW,QAAA,cAAc,kBAwCzB;AAEK,MAAM,sBAAsB,GAAG,CACpC,QAAkB,EAClB,OAEC,EACwB,EAAE;IAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;IAErC,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,kBAAkB,GACtB,UAAU,KAAK,iBAAU,CAAC,QAAQ;QAChC,CAAC,CAAC,IAAA,6BAAqB,GAAE;QACzB,CAAC,CAAC,IAAI,oBAAa,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC;YACvC,WAAW,EAAE,UAAU,CAAC,YAAY;YACpC,OAAO,EAAE,UAAU,CAAC,QAAQ;SAC7B,CAAC,CAAC;IAET,OAAO,MAAM,IAAA,sBAAc,EAAC,GAAG,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC,CAAA,CAAC;AAlBW,QAAA,sBAAsB,0BAkBjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getOrgData: (orgId: string) => Promise<any>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getOrgData = void 0;
|
|
16
|
+
const api_1 = require("./api");
|
|
17
|
+
const path_1 = require("./auth/path");
|
|
18
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
19
|
+
const getOrgData = (orgId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
// Try to read the org data from the bootstrap file first
|
|
22
|
+
const bootstrapOrgDataPath = (0, path_1.getBootstrapOrgDataPath)(orgId);
|
|
23
|
+
const buffer = yield promises_1.default.readFile(bootstrapOrgDataPath);
|
|
24
|
+
return JSON.parse(buffer.toString());
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
// ... if that fails, fetch it via API
|
|
28
|
+
try {
|
|
29
|
+
return yield (0, api_1.fetchOrgData)(orgId);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (typeof e === "string" && e.startsWith("Network error:")) {
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
if (typeof e === "string" && e.startsWith("Not found")) {
|
|
36
|
+
throw "Could not find organization";
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.getOrgData = getOrgData;
|
|
43
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.js","sourceRoot":"","sources":["../../../src/drivers/org.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAWA,+BAAqC;AACrC,sCAAsD;AACtD,2DAA6B;AAEtB,MAAM,UAAU,GAAG,CAAO,KAAa,EAAE,EAAE;IAChD,IAAI;QACF,yDAAyD;QACzD,MAAM,oBAAoB,GAAG,IAAA,8BAAuB,EAAC,KAAK,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;KACtC;IAAC,OAAO,GAAG,EAAE;QACZ,sCAAsC;QACtC,IAAI;YACF,OAAO,MAAM,IAAA,kBAAY,EAAa,KAAK,CAAC,CAAC;SAC9C;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;gBAC3D,MAAM,CAAC,CAAC;aACT;YACD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACtD,MAAM,6BAA6B,CAAC;aACrC;YACD,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC,CAAA,CAAC;AApBW,QAAA,UAAU,cAoBrB"}
|
|
@@ -20,14 +20,12 @@ This file is part of @p0security/cli
|
|
|
20
20
|
|
|
21
21
|
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
|
|
22
22
|
**/
|
|
23
|
-
const
|
|
24
|
-
const firestore_2 = require("firebase/firestore");
|
|
23
|
+
const api_1 = require("../../drivers/api");
|
|
25
24
|
const lodash_1 = require("lodash");
|
|
26
25
|
const getFirstAwsConfig = (authn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
26
|
var _a;
|
|
28
27
|
const { identity } = authn;
|
|
29
|
-
const
|
|
30
|
-
const config = snapshot.data();
|
|
28
|
+
const { config } = yield (0, api_1.fetchIntegrationConfig)(authn, "aws");
|
|
31
29
|
const item = Object.entries((_a = config === null || config === void 0 ? void 0 : config["iam-write"]) !== null && _a !== void 0 ? _a : {}).find(([_id, { state }]) => state === "installed");
|
|
32
30
|
if (!item)
|
|
33
31
|
throw `P0 is not installed on any AWS account`;
|
|
@@ -37,8 +35,7 @@ exports.getFirstAwsConfig = getFirstAwsConfig;
|
|
|
37
35
|
const getAwsConfig = (authn, account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
36
|
var _b;
|
|
39
37
|
const { identity } = authn;
|
|
40
|
-
const
|
|
41
|
-
const config = snapshot.data();
|
|
38
|
+
const { config } = yield (0, api_1.fetchIntegrationConfig)(authn, "aws");
|
|
42
39
|
// TODO: Support alias lookup
|
|
43
40
|
const allItems = (0, lodash_1.sortBy)(Object.entries((_b = config === null || config === void 0 ? void 0 : config["iam-write"]) !== null && _b !== void 0 ? _b : {}).filter(([, { state }]) => state === "installed"), ([id]) => id);
|
|
44
41
|
const item = account
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/plugins/aws/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/plugins/aws/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,2CAA2D;AAG3D,mCAAgC;AAEzB,MAAM,iBAAiB,GAAG,CAAO,KAAY,EAAE,EAAE;;IACtD,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,4BAAsB,EAC7C,KAAK,EACL,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,WAAW,CAAC,mCAAI,EAAE,CAAC,CAAC,IAAI,CAC3D,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,WAAW,CAC5C,CAAC;IAEF,IAAI,CAAC,IAAI;QAAE,MAAM,wCA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C,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,IAAI;QAAE,MAAM,sCAAsC,OAAO,EAAE,CAAC;IACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,IAAK,IAAI,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;AAC3D,CAAC,CAAA,CAAC;AAzBW,QAAA,YAAY,gBAyBvB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.azureLogin = void 0;
|
|
16
|
+
/** Copyright © 2024-present P0 Security
|
|
17
|
+
|
|
18
|
+
This file is part of @p0security/cli
|
|
19
|
+
|
|
20
|
+
@p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
|
|
21
|
+
|
|
22
|
+
@p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
23
|
+
|
|
24
|
+
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
|
|
25
|
+
**/
|
|
26
|
+
const oidc_1 = require("../../common/auth/oidc");
|
|
27
|
+
const server_1 = require("../../common/auth/server");
|
|
28
|
+
const fetch_1 = require("../../common/fetch");
|
|
29
|
+
const stdio_1 = require("../../drivers/stdio");
|
|
30
|
+
const open_1 = __importDefault(require("open"));
|
|
31
|
+
const pkce_challenge_1 = __importDefault(require("pkce-challenge"));
|
|
32
|
+
const AZURE_SCOPE = "openid profile email offline_access";
|
|
33
|
+
const AZURE_REDIRECT_PORT = 52701;
|
|
34
|
+
const AZURE_REDIRECT_URL = `http://localhost:${AZURE_REDIRECT_PORT}`;
|
|
35
|
+
const PKCE_LENGTH = 128;
|
|
36
|
+
const requestAuth = (org) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
if (!org.providerDomain) {
|
|
38
|
+
throw "Azure login requires a configured provider domain.";
|
|
39
|
+
}
|
|
40
|
+
const pkce = yield (0, pkce_challenge_1.default)(PKCE_LENGTH);
|
|
41
|
+
const baseUrl = `https://login.microsoftonline.com/${org.providerDomain}/oauth2/v2.0/authorize`;
|
|
42
|
+
const authBody = {
|
|
43
|
+
client_id: org.clientId,
|
|
44
|
+
code_challenge: pkce.code_challenge,
|
|
45
|
+
code_challenge_method: "S256",
|
|
46
|
+
redirect_uri: AZURE_REDIRECT_URL,
|
|
47
|
+
response_type: "code",
|
|
48
|
+
scope: AZURE_SCOPE,
|
|
49
|
+
state: "azure_login",
|
|
50
|
+
};
|
|
51
|
+
const url = `${baseUrl}?${(0, fetch_1.urlEncode)(authBody)}`;
|
|
52
|
+
(0, stdio_1.print2)(`Your browser has been opened to visit:
|
|
53
|
+
|
|
54
|
+
${url}\n`);
|
|
55
|
+
(0, open_1.default)(url).catch(() => {
|
|
56
|
+
(0, stdio_1.print2)(`Please visit the following URL to continue login:
|
|
57
|
+
|
|
58
|
+
${url}`);
|
|
59
|
+
});
|
|
60
|
+
return pkce;
|
|
61
|
+
});
|
|
62
|
+
const requestToken = (org, code, pkce) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
if (!org.providerDomain) {
|
|
64
|
+
throw "Azure login requires a configured provider domain.";
|
|
65
|
+
}
|
|
66
|
+
const tokenUrl = `https://login.microsoftonline.com/${org.providerDomain}/oauth2/v2.0/token`;
|
|
67
|
+
const body = {
|
|
68
|
+
client_id: org.clientId,
|
|
69
|
+
code,
|
|
70
|
+
code_verifier: pkce.code_verifier,
|
|
71
|
+
grant_type: "authorization_code",
|
|
72
|
+
redirect_uri: AZURE_REDIRECT_URL,
|
|
73
|
+
};
|
|
74
|
+
const response = yield fetch(tokenUrl, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: Object.assign(Object.assign({}, oidc_1.OIDC_HEADERS), { Accept: "application/json", Origin: AZURE_REDIRECT_URL }),
|
|
77
|
+
body: (0, fetch_1.urlEncode)(body),
|
|
78
|
+
});
|
|
79
|
+
const valid = yield (0, fetch_1.validateResponse)(response);
|
|
80
|
+
return (yield valid.json());
|
|
81
|
+
});
|
|
82
|
+
const azureLogin = (org) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
return yield (0, server_1.withRedirectServer)(() => __awaiter(void 0, void 0, void 0, function* () { return yield requestAuth(org); }), (pkce, token) => __awaiter(void 0, void 0, void 0, function* () { return yield requestToken(org, token.code, pkce); }), { port: AZURE_REDIRECT_PORT });
|
|
84
|
+
});
|
|
85
|
+
exports.azureLogin = azureLogin;
|
|
86
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/plugins/azure/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,iDAAsD;AACtD,qDAA8D;AAC9D,8CAAiE;AACjE,+CAA6C;AAG7C,gDAAwB;AACxB,oEAA2C;AAE3C,MAAM,WAAW,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EAAE,GAAG,CAAC,QAAQ;QACvB,IAAI;QACJ,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,oBAAoB;QAChC,YAAY,EAAE,kBAAkB;KACjC,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;QACrC,MAAM,EAAE,MAAM;QACd,OAAO,kCACF,mBAAY,KACf,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,kBAAkB,GAC3B;QACD,IAAI,EAAE,IAAA,iBAAS,EAAC,IAAI,CAAC;KACtB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,IAAA,wBAAgB,EAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAkB,CAAC;AAC/C,CAAC,CAAA,CAAC;AAEK,MAAM,UAAU,GAAG,CAAO,GAAY,EAA0B,EAAE;IACvE,OAAO,MAAM,IAAA,2BAAkB,EAC7B,GAAS,EAAE,kDAAC,OAAA,MAAM,WAAW,CAAC,GAAG,CAAC,CAAA,GAAA,EAClC,CAAO,IAAI,EAAE,KAAK,EAAE,EAAE,kDAAC,OAAA,MAAM,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA,GAAA,EAChE,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAC9B,CAAC;AACJ,CAAC,CAAA,CAAC;AANW,QAAA,UAAU,cAMrB"}
|
|
@@ -22,6 +22,7 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
22
22
|
**/
|
|
23
23
|
const subprocess_1 = require("../../common/subprocess");
|
|
24
24
|
const stdio_1 = require("../../drivers/stdio");
|
|
25
|
+
const util_1 = require("../../util");
|
|
25
26
|
/**
|
|
26
27
|
* Adds an ssh public key to the user object's sshPublicKeys array in Google Workspace.
|
|
27
28
|
* GCP OS Login uses these public keys to authenticate the user.
|
|
@@ -36,16 +37,15 @@ const stdio_1 = require("../../drivers/stdio");
|
|
|
36
37
|
const importSshKey = (publicKey, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
38
|
var _a;
|
|
38
39
|
const debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false;
|
|
40
|
+
const isWindows = (0, util_1.getOperatingSystem)() === "win";
|
|
41
|
+
const cmd = isWindows ? "cmd.exe" : "gcloud";
|
|
39
42
|
// Force debug=false otherwise it prints the access token
|
|
40
|
-
const accessToken = yield (0, subprocess_1.asyncSpawn)({ debug: false },
|
|
41
|
-
"auth",
|
|
42
|
-
"print-access-token"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"config",
|
|
46
|
-
"get-value",
|
|
47
|
-
"account",
|
|
48
|
-
]);
|
|
43
|
+
const accessToken = yield (0, subprocess_1.asyncSpawn)({ debug: false }, cmd, isWindows
|
|
44
|
+
? ["/d", "/s", "/c", "gcloud", "auth", "print-access-token"]
|
|
45
|
+
: ["auth", "print-access-token"]);
|
|
46
|
+
const account = yield (0, subprocess_1.asyncSpawn)({ debug }, cmd, isWindows
|
|
47
|
+
? ["/d", "/s", "/c", "gcloud", "config", "get-value", "account"]
|
|
48
|
+
: ["config", "get-value", "account"]);
|
|
49
49
|
if (debug) {
|
|
50
50
|
(0, stdio_1.print2)(`Retrieved access token ${accessToken.slice(0, 10)}... for account ${account}`);
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-key.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wDAAqD;AACrD,+CAA6C;
|
|
1
|
+
{"version":3,"file":"ssh-key.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wDAAqD;AACrD,+CAA6C;AAC7C,qCAAgD;AAGhD;;;;;;;;;;GAUG;AAC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value: true });
|
|
|
12
12
|
exports.awsCloudAuth = exports.aliasedArn = exports.profileName = exports.requestAccessToCluster = exports.getAndValidateK8sIntegration = void 0;
|
|
13
13
|
const shared_1 = require("../../commands/shared");
|
|
14
14
|
const request_1 = require("../../commands/shared/request");
|
|
15
|
-
const
|
|
16
|
-
const stdio_1 = require("../../drivers/stdio");
|
|
15
|
+
const api_1 = require("../../drivers/api");
|
|
17
16
|
const util_1 = require("../../util");
|
|
18
17
|
const config_1 = require("../aws/config");
|
|
19
18
|
const idc_1 = require("../aws/idc");
|
|
20
19
|
const utils_1 = require("../aws/utils");
|
|
21
20
|
const aws_1 = require("../okta/aws");
|
|
22
|
-
const firestore_2 = require("firebase/firestore");
|
|
23
21
|
const lodash_1 = require("lodash");
|
|
22
|
+
const typescript_1 = require("typescript");
|
|
24
23
|
const KUBECONFIG_PREFIX = "p0";
|
|
25
24
|
const getAndValidateK8sIntegration = (authn, clusterId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
var _a
|
|
27
|
-
const configDoc = yield (0,
|
|
25
|
+
var _a;
|
|
26
|
+
const configDoc = yield (0, api_1.fetchIntegrationConfig)(authn, "k8s");
|
|
28
27
|
// Validation done here in lieu of the backend, since the backend doesn't validate until approval. TODO: ENG-2365.
|
|
29
|
-
const config = (
|
|
28
|
+
const config = (_a = configDoc.config["iam-write"]) === null || _a === void 0 ? void 0 : _a[clusterId];
|
|
30
29
|
if (!config) {
|
|
31
30
|
throw `Cluster with ID ${clusterId} not found`;
|
|
32
31
|
}
|
|
@@ -69,8 +68,11 @@ const requestAccessToCluster = (authn, args, clusterId, role) => __awaiter(void
|
|
|
69
68
|
if (!response) {
|
|
70
69
|
throw "Did not receive access ID from server";
|
|
71
70
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
71
|
+
const code = yield (0, shared_1.decodeProvisionStatus)(response.request);
|
|
72
|
+
if (!code) {
|
|
73
|
+
typescript_1.sys.exit(1);
|
|
74
|
+
}
|
|
75
|
+
return response.request;
|
|
74
76
|
});
|
|
75
77
|
exports.requestAccessToCluster = requestAccessToCluster;
|
|
76
78
|
const profileName = (eksCluterName) => `${KUBECONFIG_PREFIX}-${eksCluterName}`;
|
|
@@ -78,13 +80,13 @@ exports.profileName = profileName;
|
|
|
78
80
|
const aliasedArn = (eksCluterArn) => `${KUBECONFIG_PREFIX}-${eksCluterArn}`;
|
|
79
81
|
exports.aliasedArn = aliasedArn;
|
|
80
82
|
const awsCloudAuth = (authn, awsAccountId, request, loginType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
-
var
|
|
83
|
+
var _b;
|
|
82
84
|
const { permission, generated } = request;
|
|
83
85
|
const { eksGenerated } = generated;
|
|
84
86
|
const { name } = eksGenerated;
|
|
85
87
|
switch (loginType) {
|
|
86
88
|
case "idc": {
|
|
87
|
-
const { idcId, idcRegion } = (
|
|
89
|
+
const { idcId, idcRegion } = (_b = permission.awsResourcePermission) !== null && _b !== void 0 ? _b : {};
|
|
88
90
|
if (!idcId || !idcRegion) {
|
|
89
91
|
throw "AWS is configured to use Identity Center, but IDC information wasn't received in the request.";
|
|
90
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/kubeconfig/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/kubeconfig/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,kDAA8D;AAC9D,2DAAwD;AACxD,2CAA2D;AAG3D,qCAAyC;AACzC,0CAA6C;AAC7C,oCAA+C;AAE/C,wCAAwC;AACxC,qCAAqD;AAErD,mCAA8B;AAC9B,2CAAiC;AAGjC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAExB,MAAM,4BAA4B,GAAG,CAC1C,KAAY,EACZ,SAAiB,EAQhB,EAAE;;IACH,MAAM,SAAS,GAAG,MAAM,IAAA,4BAAsB,EAC5C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,YAAY,EAAE,CAAC;AAD5B,QAAA,UAAU,cACkB;AAElC,MAAM,YAAY,GAAG,CAC1B,KAAY,EACZ,YAAoB,EACpB,OAA6C,EAC7C,SAA8B,EACL,EAAE;;IAC3B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAE9B,QAAQ,SAAS,EAAE;QACjB,KAAK,KAAK,CAAC,CAAC;YACV,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAA,UAAU,CAAC,qBAAqB,mCAAI,EAAE,CAAC;YAEpE,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE;gBACxB,MAAM,+FAA+F,CAAC;aACvG;YAED,OAAO,MAAM,IAAA,uBAAiB,EAAC;gBAC7B,SAAS,EAAE,YAAY;gBACvB,aAAa,EAAE,IAAI;gBACnB,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE;aACtC,CAAC,CAAC;SACJ;QACD,KAAK,WAAW;YACd,OAAO,MAAM,IAAA,4BAAsB,EAAC,KAAK,EAAE;gBACzC,SAAS,EAAE,YAAY;gBACvB,IAAI,EAAE,IAAI;aACX,CAAC,CAAC;QACL;YACE,MAAM,IAAA,kBAAW,EAAC,SAAS,CAAC,CAAC;KAChC;AACH,CAAC,CAAA,CAAC;AAhCW,QAAA,YAAY,gBAgCvB"}
|
|
@@ -10,10 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.pluginLoginMap = void 0;
|
|
13
|
-
const login_1 = require("./
|
|
14
|
-
const login_2 = require("./
|
|
15
|
-
const login_3 = require("./
|
|
16
|
-
const login_4 = require("./
|
|
13
|
+
const login_1 = require("./azure/login");
|
|
14
|
+
const login_2 = require("./email/login");
|
|
15
|
+
const login_3 = require("./google/login");
|
|
16
|
+
const login_4 = require("./okta/login");
|
|
17
|
+
const login_5 = require("./ping/login");
|
|
17
18
|
const loginPlugins = [
|
|
18
19
|
"google",
|
|
19
20
|
"okta",
|
|
@@ -25,11 +26,12 @@ const loginPlugins = [
|
|
|
25
26
|
"aws-oidc",
|
|
26
27
|
];
|
|
27
28
|
exports.pluginLoginMap = {
|
|
28
|
-
google:
|
|
29
|
-
okta:
|
|
30
|
-
ping:
|
|
31
|
-
"google-oidc":
|
|
29
|
+
google: login_3.googleLogin,
|
|
30
|
+
okta: login_4.oktaLogin,
|
|
31
|
+
ping: login_5.pingLogin,
|
|
32
|
+
"google-oidc": login_3.googleLogin,
|
|
32
33
|
"oidc-pkce": (org) => __awaiter(void 0, void 0, void 0, function* () { return yield exports.pluginLoginMap[org.providerType](org); }),
|
|
33
|
-
password:
|
|
34
|
+
password: login_2.emailPasswordLogin,
|
|
35
|
+
"azure-oidc": login_1.azureLogin,
|
|
34
36
|
};
|
|
35
37
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/plugins/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,yCAAmD;AACnD,0CAA6C;AAC7C,wCAAyC;AACzC,wCAAyC;AAEzC,MAAM,YAAY,GAAG;IACnB,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;IACb,UAAU;CACF,CAAC;AAIE,QAAA,cAAc,GAGvB;IACF,MAAM,EAAE,mBAAW;IACnB,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,iBAAS;IACf,aAAa,EAAE,mBAAW;IAC1B,WAAW,EAAE,CAAO,GAAG,EAAE,EAAE,kDAAC,OAAA,MAAM,sBAAc,CAAC,GAAG,CAAC,YAAa,CAAE,CAAC,GAAG,CAAC,CAAA,GAAA;IACzE,QAAQ,EAAE,0BAAkB;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/plugins/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,yCAA2C;AAC3C,yCAAmD;AACnD,0CAA6C;AAC7C,wCAAyC;AACzC,wCAAyC;AAEzC,MAAM,YAAY,GAAG;IACnB,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;IACb,UAAU;CACF,CAAC;AAIE,QAAA,cAAc,GAGvB;IACF,MAAM,EAAE,mBAAW;IACnB,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,iBAAS;IACf,aAAa,EAAE,mBAAW;IAC1B,WAAW,EAAE,CAAO,GAAG,EAAE,EAAE,kDAAC,OAAA,MAAM,sBAAc,CAAC,GAAG,CAAC,YAAa,CAAE,CAAC,GAAG,CAAC,CAAA,GAAA;IACzE,QAAQ,EAAE,0BAAkB;IAC5B,YAAY,EAAE,kBAAU;CACzB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.selfHostedSshProvider = void 0;
|
|
13
|
+
/** Copyright © 2024-present P0 Security
|
|
14
|
+
|
|
15
|
+
This file is part of @p0security/cli
|
|
16
|
+
|
|
17
|
+
@p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
|
|
18
|
+
|
|
19
|
+
@p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
|
|
22
|
+
**/
|
|
23
|
+
const ssh_1 = require("../../commands/shared/ssh");
|
|
24
|
+
const keys_1 = require("../../common/keys");
|
|
25
|
+
const api_1 = require("../../drivers/api");
|
|
26
|
+
const PROPAGATION_TIMEOUT_LIMIT_MS = 2 * 60 * 1000;
|
|
27
|
+
const unprovisionedAccessPatterns = [
|
|
28
|
+
{ pattern: /Permission denied \(publickey\)/ },
|
|
29
|
+
{
|
|
30
|
+
// The output of `sudo -v` when the user is not allowed to run sudo
|
|
31
|
+
pattern: /Sorry, user .+ may not run sudo on .+/,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
exports.selfHostedSshProvider = {
|
|
35
|
+
cloudProviderLogin: () => __awaiter(void 0, void 0, void 0, function* () { return undefined; }),
|
|
36
|
+
ensureInstall: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
37
|
+
friendlyName: "Self-hosted",
|
|
38
|
+
loginRequiredMessage: "Please login to P0 CLI with 'p0 login'",
|
|
39
|
+
propagationTimeoutMs: PROPAGATION_TIMEOUT_LIMIT_MS,
|
|
40
|
+
preTestAccessPropagationArgs: (cmdArgs) => {
|
|
41
|
+
if ((0, ssh_1.isSudoCommand)(cmdArgs)) {
|
|
42
|
+
return Object.assign(Object.assign({}, cmdArgs), {
|
|
43
|
+
// `sudo -v` prints `Sorry, user <user> may not run sudo on <hostname>.` to stderr when user is not a sudoer.
|
|
44
|
+
// It prints nothing to stdout when user is a sudoer - which is important because we don't want any output from the pre-test.
|
|
45
|
+
command: "sudo", arguments: ["-v"] });
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
},
|
|
49
|
+
generateKeys: (_) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
return {
|
|
51
|
+
privateKeyPath: keys_1.PRIVATE_KEY_PATH,
|
|
52
|
+
};
|
|
53
|
+
}),
|
|
54
|
+
proxyCommand: (request, port) => {
|
|
55
|
+
return ["nc", request.id, port !== null && port !== void 0 ? port : "22"];
|
|
56
|
+
},
|
|
57
|
+
reproCommands: () => undefined,
|
|
58
|
+
requestToSsh: (request) => {
|
|
59
|
+
return {
|
|
60
|
+
id: request.permission.resource.publicIp,
|
|
61
|
+
linuxUserName: request.generated.linuxUserName,
|
|
62
|
+
type: "self-hosted",
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
unprovisionedAccessPatterns,
|
|
66
|
+
toCliRequest: (request) => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign(Object.assign({}, request), { cliLocalData: undefined })); }),
|
|
67
|
+
submitPublicKey(authn, request, requestId, publicKey) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
if (request.generated.publicKey) {
|
|
70
|
+
if (request.generated.publicKey !== publicKey) {
|
|
71
|
+
throw "Public key mismatch. Please revoke the request and try again.";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
yield (0, api_1.submitPublicKey)(authn, { publicKey, requestId });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=ssh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../../src/plugins/self-hosted/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAA0D;AAC1D,4CAAqD;AACrD,2CAAoD;A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AAY,EAAE,CAAO,OAAO,EAAE,EAAE,kDAAC,OAAA,iCAAM,OAAO,KAAE,YAAY,EAAE,SAAS,IAAG,CAAA,GAAA;IAEpE,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;;YACxD,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE;gBAC/B,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS,KAAK,SAAS,EAAE;oBAC7C,MAAM,+DAA+D,CAAC;iBACvE;aACF;iBAAM;gBACL,MAAM,IAAA,qBAAe,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;aACxD;QACH,CAAC;KAAA;CACF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Copyright © 2024-present P0 Security
|
|
2
|
+
|
|
3
|
+
This file is part of @p0security/cli
|
|
4
|
+
|
|
5
|
+
@p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
|
|
6
|
+
|
|
7
|
+
@p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
8
|
+
|
|
9
|
+
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
|
|
10
|
+
**/
|
|
11
|
+
import { PermissionSpec } from "../../types/request";
|
|
12
|
+
import { CliPermissionSpec } from "../../types/ssh";
|
|
13
|
+
import { CommonSshPermissionSpec } from "../ssh/types";
|
|
14
|
+
export type SelfHostedSshPermission = CommonSshPermissionSpec & {
|
|
15
|
+
provider: "self-hosted";
|
|
16
|
+
resource: {
|
|
17
|
+
hostname: string;
|
|
18
|
+
publicIp: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type SelfHostedSshGenerated = {
|
|
22
|
+
linuxUserName: string;
|
|
23
|
+
publicKey: string;
|
|
24
|
+
};
|
|
25
|
+
export type SelfHostedSshPermissionSpec = PermissionSpec<"ssh", SelfHostedSshPermission, SelfHostedSshGenerated>;
|
|
26
|
+
export type SelfHostedSsh = CliPermissionSpec<SelfHostedSshPermissionSpec, undefined>;
|
|
27
|
+
export type SelfHostedSshRequest = {
|
|
28
|
+
type: "self-hosted";
|
|
29
|
+
linuxUserName: string;
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/plugins/self-hosted/types.ts"],"names":[],"mappings":""}
|