Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

groupsRequired Middleware iterator not firing #625

Open
mrosenberg opened this issue Aug 3, 2017 · 3 comments
Open

groupsRequired Middleware iterator not firing #625

mrosenberg opened this issue Aug 3, 2017 · 3 comments

Comments

@mrosenberg
Copy link

lib/middleware/groups-required.js

        userGroups.each(
          function (group, iterateNext) {
            if (groups.indexOf(group.name) > -1) {
              if (!all || --done === 0) {
                isInGroup = true;
              }
            }
            iterateNext();
          },
          function () {
            callback(null, isInGroup);
          }
        );

The first function never fires, it looks like the underlying collection's items property is empty even though the groups are expanded on the user object.

@nbarbettini
Copy link
Member

I've reproduced this and definitely think it's a bug.

Steps:

router.get('/profile', stormpath.groupsRequired(['Everyone'], false), function(req, res) {
  res.render('profile');
});
  • Log in with a user in the Everyone group (I've tried other custom groups as well) and try to access /profile - the Unauthorized page is displayed

Looks like it's because of this code: https://github.com/stormpath/stormpath-sdk-node/blob/okta/lib/resource/Group.js#L129-L134
This skips any groups that don't start with group: which means any custom groups created after the import can't be used with groupsRequired middleware.

@gvdhorst
Copy link

express-sprtmpath skipping groups that don't start with group: indeed seems to be the problem.

As a workaround you can prefixing all group names with group: (in both stormpath.groupsRequired() and the Okta control panel).

@mrosenberg
Copy link
Author

I wrote a custom middleware to handle this use case for us so I'm fine with closing this. I'll revisit this once the Okta Node SDK is stable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants