djangopythonsecuritysoftware-development

Manage user groups and permissions with YAML in Django

2 min read

Manage user groups and permissions with YAML in Django

--

As you might have read on our blog, we are big fans of configuration and infrastructure as code principles. It improves the baseline quality, makes stuff easier to maintain and improves speed and reusability across your projects and environments.

One of our latest open source projects in this category is django-perms-provisioner.

This project allows you to codify the groups and permissions structure of your Django projects, instead of dumping and loading these via database fixtures or worse, recreating them by hand per environment.

With a simple, version-controlled YAML file, you can define groups and permissions for your project:

---groups: - name: Group Name permissions: sites: - site.add_site - site.change_site wagtailadmin: - admin.access_admin

And with a simple command you can create these in your environment:

./manage.py loadperms permissions.yaml

Say you want to convert an existing permissions structure in your database into a YAML file, that’s also possible with the following command.

./manage.py dumpperms > permissions.yaml

We believe this will make it easier to standardise and maintain User & Group permissions in Django projects, and will therefore improve and simplify overall security!

To get started with the module, please see the Github repo.

And as always, contributions are welcome!

Tags used in this article:
djangopythonsecuritysoftware-development