@p0security/cli 0.21.1 → 0.22.1

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.
@@ -10,16 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.pingLogin = 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 authUtils_1 = require("../../types/authUtils");
13
24
  const login_1 = require("../oidc/login");
14
25
  /** Logs in to PingOne via OIDC */
15
26
  const pingLogin = (org) => __awaiter(void 0, void 0, void 0, function* () {
16
27
  return (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, "openid email profile", () => {
17
- if (org.providerType !== "ping" || org.providerType === undefined) {
18
- throw `Invalid provider type ${org.providerType} (expected "ping")`;
28
+ const providerType = (0, authUtils_1.getProviderType)(org);
29
+ const providerDomain = (0, authUtils_1.getProviderDomain)(org);
30
+ const environmentId = (0, authUtils_1.getEnvironmentId)(org);
31
+ if (providerType !== "ping" || !providerDomain || !environmentId) {
32
+ throw `Invalid provider ${providerType} (expected ping OIDC provider)`;
19
33
  }
20
34
  return {
21
- deviceAuthorizationUrl: `https://${org.providerDomain}/${org.environmentId}/as/device_authorization`,
22
- tokenUrl: `https://${org.providerDomain}/${org.environmentId}/as/token`,
35
+ deviceAuthorizationUrl: `https://${providerDomain}/${environmentId}/as/device_authorization`,
36
+ tokenUrl: `https://${providerDomain}/${environmentId}/as/token`,
23
37
  };
24
38
  }));
25
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/plugins/ping/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,yCAA0D;AAE1D,kCAAkC;AAC3B,MAAM,SAAS,GAAG,CAAO,GAAY,EAAE,EAAE;IAC9C,OAAA,IAAA,iBAAS,EACP,IAAA,sBAAc,EAAC,GAAG,EAAE,sBAAsB,EAAE,GAAG,EAAE;QAC/C,IAAI,GAAG,CAAC,YAAY,KAAK,MAAM,IAAI,GAAG,CAAC,YAAY,KAAK,SAAS,EAAE;YACjE,MAAM,yBAAyB,GAAG,CAAC,YAAY,oBAAoB,CAAC;SACrE;QACD,OAAO;YACL,sBAAsB,EAAE,WAAW,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,aAAa,0BAA0B;YACpG,QAAQ,EAAE,WAAW,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,aAAa,WAAW;SACxE,CAAC;IACJ,CAAC,CAAC,CACH,CAAA;EAAA,CAAC;AAXS,QAAA,SAAS,aAWlB"}
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/plugins/ping/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,qDAI+B;AAG/B,yCAA0D;AAE1D,kCAAkC;AAC3B,MAAM,SAAS,GAAG,CAAO,GAAY,EAAE,EAAE;IAC9C,OAAA,IAAA,iBAAS,EACP,IAAA,sBAAc,EAAC,GAAG,EAAE,sBAAsB,EAAE,GAAG,EAAE;QAC/C,MAAM,YAAY,GAAG,IAAA,2BAAe,EAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,aAAa,GAAG,IAAA,4BAAgB,EAAC,GAAG,CAAC,CAAC;QAE5C,IAAI,YAAY,KAAK,MAAM,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,EAAE;YAChE,MAAM,oBAAoB,YAAY,gCAAgC,CAAC;SACxE;QACD,OAAO;YACL,sBAAsB,EAAE,WAAW,cAAc,IAAI,aAAa,0BAA0B;YAC5F,QAAQ,EAAE,WAAW,cAAc,IAAI,aAAa,WAAW;SAChE,CAAC;IACJ,CAAC,CAAC,CACH,CAAA;EAAA,CAAC;AAfS,QAAA,SAAS,aAelB"}
@@ -0,0 +1,28 @@
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 type { OrgData } from "./org";
12
+ /** Helper functions to access auth fields */
13
+ /** Get provider type from org data */
14
+ export declare const getProviderType: (org: OrgData) => "cloudflare" | "okta" | "ping" | undefined;
15
+ /** Get provider domain from org data */
16
+ export declare const getProviderDomain: (org: OrgData) => string | undefined;
17
+ /** Get client ID from org data */
18
+ export declare const getClientId: (org: OrgData) => string | undefined;
19
+ /** Get environment ID from org data */
20
+ export declare const getEnvironmentId: (org: OrgData) => string | undefined;
21
+ /** Get SSO provider from org data */
22
+ export declare const getSsoProvider: (org: OrgData) => string | undefined;
23
+ /** Get provider ID from org data */
24
+ export declare const getProviderId: (org: OrgData) => string | undefined;
25
+ /** Check if org uses password authentication */
26
+ export declare const usePasswordAuth: (org: OrgData) => boolean;
27
+ /** Get Microsoft primary domain from org data (for Azure/Microsoft providers) */
28
+ export declare const getMicrosoftPrimaryDomain: (org: OrgData) => string | undefined;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMicrosoftPrimaryDomain = exports.usePasswordAuth = exports.getProviderId = exports.getSsoProvider = exports.getEnvironmentId = exports.getClientId = exports.getProviderDomain = exports.getProviderType = void 0;
4
+ /** Helper functions to access auth fields */
5
+ /** Get provider type from org data */
6
+ const getProviderType = (org) => {
7
+ return org.auth.type === "sso" && "providerType" in org.auth.provider
8
+ ? org.auth.provider.providerType
9
+ : undefined;
10
+ };
11
+ exports.getProviderType = getProviderType;
12
+ /** Get provider domain from org data */
13
+ const getProviderDomain = (org) => {
14
+ return org.auth.type === "sso" && "providerDomain" in org.auth.provider
15
+ ? org.auth.provider.providerDomain
16
+ : undefined;
17
+ };
18
+ exports.getProviderDomain = getProviderDomain;
19
+ /** Get client ID from org data */
20
+ const getClientId = (org) => {
21
+ return org.auth.type === "sso" && "clientId" in org.auth.provider
22
+ ? org.auth.provider.clientId
23
+ : undefined;
24
+ };
25
+ exports.getClientId = getClientId;
26
+ /** Get environment ID from org data */
27
+ const getEnvironmentId = (org) => {
28
+ return org.auth.type === "sso" && "environmentId" in org.auth.provider
29
+ ? org.auth.provider.environmentId
30
+ : undefined;
31
+ };
32
+ exports.getEnvironmentId = getEnvironmentId;
33
+ /** Get SSO provider from org data */
34
+ const getSsoProvider = (org) => {
35
+ return org.auth.type === "sso" ? org.auth.provider.ssoProvider : undefined;
36
+ };
37
+ exports.getSsoProvider = getSsoProvider;
38
+ /** Get provider ID from org data */
39
+ const getProviderId = (org) => {
40
+ return org.auth.type === "sso" && "providerId" in org.auth.provider
41
+ ? org.auth.provider.providerId
42
+ : undefined;
43
+ };
44
+ exports.getProviderId = getProviderId;
45
+ /** Check if org uses password authentication */
46
+ const usePasswordAuth = (org) => {
47
+ return org.auth.type === "password";
48
+ };
49
+ exports.usePasswordAuth = usePasswordAuth;
50
+ /** Get Microsoft primary domain from org data (for Azure/Microsoft providers) */
51
+ const getMicrosoftPrimaryDomain = (org) => {
52
+ return org.auth.type === "sso" &&
53
+ "microsoftPrimaryDomain" in org.auth.provider
54
+ ? org.auth.provider.microsoftPrimaryDomain
55
+ : undefined;
56
+ };
57
+ exports.getMicrosoftPrimaryDomain = getMicrosoftPrimaryDomain;
58
+ //# sourceMappingURL=authUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authUtils.js","sourceRoot":"","sources":["../../../src/types/authUtils.ts"],"names":[],"mappings":";;;AAYA,6CAA6C;AAE7C,sCAAsC;AAC/B,MAAM,eAAe,GAAG,CAC7B,GAAY,EACgC,EAAE;IAC9C,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,cAAc,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ;QACnE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY;QAChC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEF,wCAAwC;AACjC,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAsB,EAAE;IACpE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,gBAAgB,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ;QACrE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAClC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAJW,QAAA,iBAAiB,qBAI5B;AAEF,kCAAkC;AAC3B,MAAM,WAAW,GAAG,CAAC,GAAY,EAAsB,EAAE;IAC9D,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ;QAC/D,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ;QAC5B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAJW,QAAA,WAAW,eAItB;AAEF,uCAAuC;AAChC,MAAM,gBAAgB,GAAG,CAAC,GAAY,EAAsB,EAAE;I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AS,CAAC;AAChB,CAAC,CAAC;AALW,QAAA,yBAAyB,6BAKpC"}
@@ -30,24 +30,67 @@ export type GoogleApplicationConfig = ApplicationConfig & {
30
30
  };
31
31
  };
32
32
  export type Config = ApplicationConfig | GoogleApplicationConfig;
33
- type BaseOrgData = {
33
+ type GoogleOidcProvider = {
34
+ ssoProvider: "google-oidc";
35
+ };
36
+ type GoogleSsoProvider = {
37
+ ssoProvider: "google";
38
+ };
39
+ type LegacyOktaSsoProvider = {
40
+ ssoProvider: "okta";
41
+ providerId: string;
42
+ };
43
+ type CommonOidcProvider = {
44
+ providerId: string;
45
+ providerDomain: string;
34
46
  clientId: string;
47
+ };
48
+ type AzureOidcProvider = Partial<CommonOidcProvider> & {
49
+ ssoProvider: "azure-oidc";
50
+ microsoftPrimaryDomain: string;
51
+ };
52
+ type MicrosoftSsoProvider = Partial<CommonOidcProvider> & {
53
+ ssoProvider: "microsoft";
54
+ microsoftPrimaryDomain: string;
55
+ };
56
+ type BaseOidcPkceProvider = {
57
+ ssoProvider: "oidc-pkce";
35
58
  providerId: string;
36
- providerDomain?: string;
37
- ssoProvider?: "azure-oidc" | "google-oidc" | "google" | "microsoft" | "oidc-pkce" | "okta";
38
- usePassword?: boolean;
59
+ providerDomain: string;
60
+ clientId: string;
61
+ };
62
+ type OktaOidcPkceProvider = BaseOidcPkceProvider & {
63
+ providerType: "okta";
64
+ authServerPath?: string;
65
+ };
66
+ type PingIdOidcPkceProvider = BaseOidcPkceProvider & {
67
+ providerType: "ping";
68
+ environmentId: string;
69
+ };
70
+ type CloudflareOidcPkceProvider = BaseOidcPkceProvider & {
71
+ providerType: "cloudflare";
72
+ clientSecret: string;
73
+ };
74
+ type OidcPkceProvider = CloudflareOidcPkceProvider | OktaOidcPkceProvider | PingIdOidcPkceProvider;
75
+ type SsoProvider = AzureOidcProvider | GoogleOidcProvider | GoogleSsoProvider | LegacyOktaSsoProvider | MicrosoftSsoProvider | OidcPkceProvider;
76
+ type OrgMagicLinkAuth = {
77
+ type: "magic-link";
78
+ };
79
+ type OrgPasswordAuth = {
80
+ type: "password";
81
+ };
82
+ type OrgSsoAuth = {
83
+ type: "sso";
84
+ provider: SsoProvider;
85
+ };
86
+ export type OrgAuth = OrgMagicLinkAuth | OrgPasswordAuth | OrgSsoAuth;
87
+ export type RawOrgData = {
39
88
  tenantId: string;
89
+ auth: OrgAuth;
40
90
  config: Config;
41
91
  /** Swaps API auth to tokens from the ssoProvider, rather than firebase */
42
92
  useProviderToken?: boolean;
43
93
  };
44
- /** Publicly readable organization data */
45
- export type RawOrgData = BaseOrgData & ({
46
- providerType?: "okta";
47
- } | {
48
- providerType?: "ping";
49
- environmentId: string;
50
- });
51
94
  export type OrgData = RawOrgData & {
52
95
  slug: string;
53
96
  };
@@ -38,4 +38,5 @@ export type RequestResponse<T> = {
38
38
  request: T;
39
39
  isPreexisting: boolean;
40
40
  isPersistent: boolean;
41
+ isPreapproved: boolean;
41
42
  };