@openinc/parse-server-opendash 3.9.6 → 3.9.8
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.
|
@@ -500,4 +500,36 @@ exports.customoptions = {
|
|
|
500
500
|
public: false,
|
|
501
501
|
description: "Use the given JWT token instead of creating a new one.",
|
|
502
502
|
},
|
|
503
|
+
MICROSOFT_CLIENT_ID: {
|
|
504
|
+
env: "OI_MICROSOFT_CLIENT_ID",
|
|
505
|
+
type: "string",
|
|
506
|
+
required: false,
|
|
507
|
+
secret: false,
|
|
508
|
+
public: false,
|
|
509
|
+
description: "Client ID for Microsoft authentication. This is the Application (client) ID from the Azure portal.",
|
|
510
|
+
},
|
|
511
|
+
MICROSOFT_CLIENT_SECRET: {
|
|
512
|
+
env: "OI_MICROSOFT_CLIENT_SECRET",
|
|
513
|
+
type: "string",
|
|
514
|
+
required: false,
|
|
515
|
+
secret: false,
|
|
516
|
+
public: false,
|
|
517
|
+
description: "Client Secret for Microsoft authentication. This is the Client Secret from the Azure portal.",
|
|
518
|
+
},
|
|
519
|
+
MICROSOFT_TENANT_ID: {
|
|
520
|
+
env: "OI_MICROSOFT_TENANT_ID",
|
|
521
|
+
type: "string",
|
|
522
|
+
required: false,
|
|
523
|
+
secret: false,
|
|
524
|
+
public: false,
|
|
525
|
+
description: "Tenant ID for Microsoft authentication. This is the Directory (tenant) ID from the Azure portal.",
|
|
526
|
+
},
|
|
527
|
+
MICROSOFT_APP_ID: {
|
|
528
|
+
env: "OI_MICROSOFT_APP_ID",
|
|
529
|
+
type: "string",
|
|
530
|
+
required: false,
|
|
531
|
+
secret: false,
|
|
532
|
+
public: false,
|
|
533
|
+
description: "Application ID for Microsoft authentication. This is the Application (client) ID from the Azure portal.",
|
|
534
|
+
},
|
|
503
535
|
};
|
|
@@ -4,11 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.init = init;
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
7
8
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
9
|
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const config_1 = require("../features/config");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const tenantId = config_1.ConfigInstance.getInstance().get("MICROSOFT_TENANT_ID");
|
|
13
|
+
const appId = config_1.ConfigInstance.getInstance().get("MICROSOFT_APP_ID");
|
|
12
14
|
// Setup JWKS client for Microsoft (replace TENANT_ID)
|
|
13
15
|
const client = (0, jwks_rsa_1.default)({
|
|
14
16
|
jwksUri: `https://login.microsoftonline.com/${tenantId}/discovery/v2.0/keys`,
|
|
@@ -29,6 +31,9 @@ async function init(name) {
|
|
|
29
31
|
Parse.Cloud.define(name, async (request) => {
|
|
30
32
|
const token = request.params.token;
|
|
31
33
|
const account = request.params.account;
|
|
34
|
+
const defaultTenant = await new Parse.Query(types_1.Tenant)
|
|
35
|
+
.ascending("createdAt")
|
|
36
|
+
.first({ useMasterKey: true });
|
|
32
37
|
if (!token) {
|
|
33
38
|
throw new Parse.Error(Parse.Error.INVALID_JSON, "Token missing");
|
|
34
39
|
}
|
|
@@ -51,6 +56,7 @@ async function init(name) {
|
|
|
51
56
|
user.set("email", account.username);
|
|
52
57
|
user.set("password", (0, crypto_1.randomBytes)(16).toString("hex")); // Generate a random password
|
|
53
58
|
user.set("name", verifiedPayload.name || verifiedPayload.preferred_username);
|
|
59
|
+
user.set("tenant", defaultTenant);
|
|
54
60
|
user = await user.signUp(null, { useMasterKey: true });
|
|
55
61
|
return user.getSessionToken();
|
|
56
62
|
}
|