Skip to content

Commit

Permalink
Merge pull request #54 from happner/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
southbite authored May 6, 2022
2 parents c43c08f + 61bd00f commit d68815d
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 106 deletions.
4 changes: 4 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ happner-cluster: 12.1.1
----------------
happn-3: 13.0.7

1.2.2 2022-05-06
----------------
happn-3: 13.0.8

88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "happner-suite",
"version": "1.2.1",
"version": "1.2.2",
"scripts": {
"test": "echo \"tests are not run from the main package of the workspace\" && exit 1",
"re-install": "rm -rf node_modules && rm -rf ./packages/*/node_modules && rm -rf package-lock.json && npm i",
Expand Down
4 changes: 4 additions & 0 deletions packages/happn-3/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,10 @@
-----------------
- TEN-112: group with permissions that have dots in them causes compaction failure

13.0.8 2022-05-06
-----------------
- TEN-114: enforce admin group save on startup




Expand Down
59 changes: 25 additions & 34 deletions packages/happn-3/lib/services/security/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,45 +393,36 @@ function AccessDeniedError(message, reason) {
return this.happn.services.error.AccessDeniedError(message, reason);
}

function __ensureAdminUser(config) {
return new Promise((resolve, reject) => {
if (!config.adminUser)
config.adminUser = {
custom_data: {},
};
if (!config.adminGroup)
config.adminGroup = {
custom_data: {
description: 'the default administration group for happn',
},
};

config.adminUser.username = '_ADMIN';
config.adminGroup.name = '_ADMIN';

config.adminGroup.permissions = {
'*': {
actions: ['*'],
async function __ensureAdminUser(config) {
if (!config.adminUser)
config.adminUser = {
custom_data: {},
};
if (!config.adminGroup)
config.adminGroup = {
custom_data: {
description: 'the default administration group for happn',
},
};

this.newDB = false;
config.adminUser.username = '_ADMIN';
config.adminGroup.name = '_ADMIN';

this.users.getUser('_ADMIN', async (e, foundUser) => {
if (e) return reject(e);
if (foundUser) return resolve();
if (!config.adminUser.password) config.adminUser.password = 'happn';
config.adminGroup.permissions = {
'*': {
actions: ['*'],
},
};
// recreate admin group, so that base system permissions are always in place
const adminGroup = await this.groups.__upsertGroup(config.adminGroup, {});
const foundUser = await this.users.getUser('_ADMIN');

try {
const adminGroup = await this.groups.__upsertGroup(config.adminGroup, {});
const adminUser = await this.users.__upsertUser(config.adminUser, {});
await this.groups.linkGroup(adminGroup, adminUser);
resolve();
} catch (e) {
reject(e);
}
});
});
if (foundUser) return;
if (!config.adminUser.password) {
config.adminUser.password = 'happn';
}
const adminUser = await this.users.__upsertUser(config.adminUser, {});
await this.groups.linkGroup(adminGroup, adminUser);
}

async function __ensureAnonymousUser(config) {
Expand Down
Loading

0 comments on commit d68815d

Please sign in to comment.