Skip to content

Commit

Permalink
fix: oidc auth groups relate / unrelate
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Sep 17, 2022
1 parent 4b30050 commit ebf4da9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/modules/authentication/oidc/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ module.exports = {
})
if (conf.mapGroups) {
const groups = _.get(profile, '_json.' + conf.groupsClaim)
if (groups) {
const groupIDs = Object.values(WIKI.auth.groups)
.filter(g => groups.includes(g.name))
.map(g => g.id)
for (let groupID of groupIDs) {
await user.$relatedQuery('groups').relate(groupID)
if (groups && _.isArray(groups)) {
const currentGroups = (await user.$relatedQuery('groups').select('groups.id')).groups.map(g => g.id)
const expectedGroups = Object.values(WIKI.auth.groups).filter(g => groups.includes(g.name)).map(g => g.id)
for (const groupId of _.difference(expectedGroups, currentGroups)) {
await user.$relatedQuery('groups').relate(groupId)
}
for (const groupId of _.difference(currentGroups, expectedGroups)) {
await user.$relatedQuery('groups').unrelate(groupId)
}
}
}
Expand Down

3 comments on commit ebf4da9

@fionera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke login with oidc group mapping and if you are logged in, the page timeouts:

2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)

@Aemilius11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke login with oidc group mapping and if you are logged in, the page timeouts:

2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)

Does this affect the Azure Active Directory Authentication Strategy in any way?

@Aemilius11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke login with oidc group mapping and if you are logged in, the page timeouts:

2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)
2022-09-22T20:34:35.948Z [MASTER] warn: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx)

Does this affect the Azure Active Directory Authentication Strategy in any way?

For anyone else stumbling upon this: It does not (#5709 (reply in thread))

Please sign in to comment.