@telia-ace/alliance-portal 1.0.6-next.3 → 1.0.6-next.4
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/CHANGELOG.md +6 -0
- package/dist/config.js +1 -0
- package/dist/graphql/generated.js +2 -1
- package/dist/index.js +16 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/config.js
CHANGED
|
@@ -7,6 +7,7 @@ var ConfigKeys;
|
|
|
7
7
|
ConfigKeys["AuthClientSecret"] = "AUTH_CLIENT_SECRET";
|
|
8
8
|
ConfigKeys["AuthClientId"] = "AUTH_CLIENT_ID";
|
|
9
9
|
ConfigKeys["AuthResponseType"] = "AUTH_RESPONSE_TYPE";
|
|
10
|
+
ConfigKeys["AuthSkipGroupClaimCheck"] = "AUTH_SKIP_GROUP_CLAIM_CHECK";
|
|
10
11
|
ConfigKeys["ServiceBaseUrl"] = "SERVICE_BASE_URL";
|
|
11
12
|
ConfigKeys["WebprovisionsTag"] = "WEBPROVISIONS_TAG";
|
|
12
13
|
ConfigKeys["WebprovisionsDistributionUrl"] = "WEBPROVISIONS_DISTRIBUTION_URL";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetUserDocument = exports.GetOrCreateUserDocument = void 0;
|
|
3
|
+
exports.GetUserDocument = exports.SetUserTypeDocument = exports.GetOrCreateUserDocument = void 0;
|
|
4
4
|
exports.GetOrCreateUserDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "GetOrCreateUser" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "GetOrCreateUserInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "getOrCreateUser" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "objectId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" } }, { "kind": "Field", "name": { "kind": "Name", "value": "type" } }] } }] } }] };
|
|
5
|
+
exports.SetUserTypeDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "SetUserType" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "SetUserTypeInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "setUserType" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }] }] } }] };
|
|
5
6
|
exports.GetUserDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUser" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "objectId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "workspaceSlug" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "String" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "user" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "objectId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "objectId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "workspaceSlug" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "workspaceSlug" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,6 @@ async function startPortal() {
|
|
|
32
32
|
displayName: claims.name || 'Empty displayName',
|
|
33
33
|
email: claims.email || claims.emails[0] || 'Empty email',
|
|
34
34
|
objectId: claims.sub || claims.oid,
|
|
35
|
-
type: hasEnterpriseAdminRole(claims) ? 'system-admin' : 'user',
|
|
36
35
|
};
|
|
37
36
|
logger.trace({
|
|
38
37
|
msg: 'decoded JWT and mapped claims to user, getting or creating user in database',
|
|
@@ -47,6 +46,22 @@ async function startPortal() {
|
|
|
47
46
|
logger.trace({ msg: 'added user to database, if it did not already exist' });
|
|
48
47
|
}
|
|
49
48
|
catch { }
|
|
49
|
+
// For easier testing as system admin during development
|
|
50
|
+
const skipGroupClaimCheck = configService.get(config_2.ConfigKeys.AuthSkipGroupClaimCheck) ===
|
|
51
|
+
'true';
|
|
52
|
+
if (!skipGroupClaimCheck) {
|
|
53
|
+
const type = hasEnterpriseAdminRole(claims) ? 'system-admin' : 'user';
|
|
54
|
+
logger.trace({ msg: 'updating user type according to user claims', type });
|
|
55
|
+
try {
|
|
56
|
+
await (0, graphql_request_1.request)(configService.getOrThrow(alliance_internal_node_utilities_1.SharedConfigKeys.DbEndpoint), graphql_1.SetUserTypeDocument, { input: { objectId: user.objectId, type } }, {
|
|
57
|
+
authorization: (0, alliance_internal_node_utilities_1.createSystemUserToken)(configService),
|
|
58
|
+
});
|
|
59
|
+
logger.trace({
|
|
60
|
+
msg: 'user type updated',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch { }
|
|
64
|
+
}
|
|
50
65
|
// FUTURE TODO: Implement some external storage for sessions, such as redis
|
|
51
66
|
// Temporary - With this the stored session cookie gets too big
|
|
52
67
|
// @ts-ignore
|