    def check_allowed_groups(self, username, authentication=None):
        """
        If allowed_groups is configured, check if authenticating user is part of group.
        """
        if not self.allowed_groups:
            return False
        user_group_gids = set(
            self._getgrouplist(username, self._getpwnam(username).pw_gid)
        )
        for grnam in self.allowed_groups:
            try:
                group = self._getgrnam(grnam)
            except KeyError:
                self.log.error(f'No such group: [{grnam}]')
                continue
            if group.gr_gid in user_group_gids:
                return True
        return False
If allowed_groups is configured, check if authenticating user is part of group.
jupyterhub/auth.py