Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtered WrapSpawner #15

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Filtered WrapSpawner #15

wants to merge 7 commits into from

Conversation

Luke035
Copy link

@Luke035 Luke035 commented Dec 18, 2017

Hi everyone,
for internal purposes we had the necessity to integrate ProfileSpawner with a filter in order to provide to each user only an allowed set of profiles based on his group. We developed this feature in the FilteredSpawner class based on ProfileSpawner.

Each spawning profile has an additional parameter that allows to define a comma-separated list of authorized user groups. If * is specified instead of the comma-separated list the profile is available for all the users.

We found this integration quite useful, and we'd like to share it with the community.

Details in the README.md, let me know for any questions.

Thank you.
L.

def get_user_groups(self):
import subprocess, sys
user = self.user.name
cmd_result = subprocess.Popen("groups "+user, shell=True, stdout=subprocess.PIPE).stdout.read()
Copy link
Member

Choose a reason for hiding this comment

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

This is not a safe or generic way to get groups. It assumes users are local on the Hub system, which is not generally true.

groups_list = cmd_result.decode(sys_encoding).split(':')[1].replace('\n', '').strip().split(' ')
return groups_list

def _user_profiles(self):
Copy link
Member

Choose a reason for hiding this comment

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

Rather than implementing logic specific to your use case (filtering based on OS groups), maybe this filter should itself be a hook and then your configuration would register the appropriate filter function for your use case?

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

Successfully merging this pull request may close these issues.

2 participants