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

Restricted accounts #788

Merged
merged 7 commits into from
Nov 26, 2023
Merged

Restricted accounts #788

merged 7 commits into from
Nov 26, 2023

Conversation

jochenklar
Copy link
Member

This PR adds the following settings:

  • PROJECT_CREATE_RESTRICTED prevents user from creating (or importing) new projects
  • PROJECT_CREATE_GROUPS allows users from groups in this list to create projects when PROJECT_CREATE_RESTRICTED = True
  • ACCOUNT_GROUPS is a list of groups which new users, who sign up using the regular allauth signup form, get added to.
  • SOCIALACCOUNT_GROUPS is a dict of lists of groups which new users, who sign up using the regular allauth signup form, get added to, seperated by provider.

E.g.

PROJECT_CREATE_RESTRICTED = True
PROJECT_CREATE_GROUPS = [
    'allauth'
]

ACCOUNT_GROUPS = ['allauth']
SOCIALACCOUNT_GROUPS = {
    'github': ['github']
}

would move all users, who sign up using the form to the allauth group and all users, who login via GitHub to the github group. Only users from the login form can create projects in this case.

LDAP and Shibboleth setups can add users to groups using their respective API.

@jochenklar jochenklar requested a review from MyPyDavid October 19, 2023 16:08
@jochenklar jochenklar self-assigned this Oct 19, 2023
@jochenklar jochenklar added this to the 2.1.0 milestone Oct 19, 2023
@coveralls
Copy link

Coverage Status

coverage: 80.521% (-0.06%) from 80.581% when pulling 7d60faf on restricted_accounts into bb5f093 on master.

@MyPyDavid
Copy link
Member

would this be interesting for a feature like this?

@jochenklar
Copy link
Member Author

Öh, the part with allauth we already do ... I don't see the need for magic links in RDMO.

@MyPyDavid MyPyDavid changed the base branch from master to dev-2.1.0 November 16, 2023 08:40
@jochenklar
Copy link
Member Author

Ok, flattened the if/else blocks, but I kept some of the else conditions for readability.

@@ -183,7 +183,7 @@ rest_framework = ["rest_framework"]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "config.settings"
testpaths = ["rdmo"]
python_files = "test_*[!.txt].py"
python_files = "test_*.py"
Copy link
Member Author

Choose a reason for hiding this comment

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

@MyPyDavid @afuetterer for some reason I still don't understand, this change removed a substantial part of our tests from the CI. The tests run, but they are not included in just running pytest. This concerned import and export. I should have investigated when the coverage dropped after 2.0.

Copy link
Member

Choose a reason for hiding this comment

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

ok, oops 🙈 , strange but good to know

Copy link
Member

Choose a reason for hiding this comment

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

Which one was problematic?
test_.py or test_[!.txt].py?

What is the meaning of test_*[!.txt].py?

Copy link
Member Author

@jochenklar jochenklar Nov 27, 2023

Choose a reason for hiding this comment

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

test_*[!.txt].py. I think @MyPyDavid wanted to exclude files like test_foo_bar.txt.py, but apparently it does not work that way. It did exclude, e.g. test_view_project_create_import.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I got it, all the missing tests got a t at the end:

test_validator_parent.py
test_viewset_import.py
test_export.py
test_validator_conflict.py
test_view_project.py
test_view_project_create_import.py
test_view_project_update_import.py
test_view_snapshot.py
test_viewset_project.py
test_viewset_project_snapshot.py
test_viewset_snapshot.py
test_viewset_questionset.py

I got the list with pytest --co with and without the pattern and some grepping.

The pattern means that the file must not end with .tx before the .py.

@jochenklar jochenklar merged commit faf201f into dev-2.1.0 Nov 26, 2023
12 checks passed
@jochenklar jochenklar deleted the restricted_accounts branch December 12, 2023 13:39
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.

4 participants