From 22a0b07f36543c708c64f01020d1055d9c65c869 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Fri, 29 Mar 2019 11:41:06 +0100 Subject: [PATCH 1/2] agent: provision role authentication levels --- hobo/agent/authentic2/provisionning.py | 1 + .../common/management/commands/hobo_notify.py | 6 +++++- .../common/migrations/0003_role_auth_level.py | 20 +++++++++++++++++++ hobo/agent/common/models.py | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 hobo/agent/common/migrations/0003_role_auth_level.py diff --git a/hobo/agent/authentic2/provisionning.py b/hobo/agent/authentic2/provisionning.py index f21dbda..4ddfc53 100644 --- a/hobo/agent/authentic2/provisionning.py +++ b/hobo/agent/authentic2/provisionning.py @@ -203,6 +203,7 @@ class Provisionning(object): 'details': role.details, 'emails': role.emails, 'emails_to_members': role.emails_to_members, + 'auth_level': role.auth_level, } for role in roles ] else: diff --git a/hobo/agent/common/management/commands/hobo_notify.py b/hobo/agent/common/management/commands/hobo_notify.py index b5630c1..4d58253 100644 --- a/hobo/agent/common/management/commands/hobo_notify.py +++ b/hobo/agent/common/management/commands/hobo_notify.py @@ -148,7 +148,8 @@ class Command(BaseCommand): role, created = Role.objects.get_or_create( name=role_name, defaults={ 'uuid': o['uuid'], - 'description': o['description']}) + 'description': o['description'], + 'auth_level': o['auth_level']}) except IntegrityError: # Can happen if uuid and name already exist logger.error(u'cannot provision role "%s" (%s)', o['name'], o['uuid']) @@ -167,6 +168,9 @@ class Command(BaseCommand): if role.details != o.get('details', u''): role.details = o.get('details', u'') save = True + if role.auth_level != o['auth_level']: + role.auth_level = o['auth_level'] + save = True if save: try: with atomic(): diff --git a/hobo/agent/common/migrations/0003_role_auth_level.py b/hobo/agent/common/migrations/0003_role_auth_level.py new file mode 100644 index 0000000..371a446 --- /dev/null +++ b/hobo/agent/common/migrations/0003_role_auth_level.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-04-18 14:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0002_auto_20160105_1702'), + ] + + operations = [ + migrations.AddField( + model_name='role', + name='auth_level', + field=models.PositiveSmallIntegerField(default=1), + ), + ] diff --git a/hobo/agent/common/models.py b/hobo/agent/common/models.py index 6c3463f..fc7f1b6 100644 --- a/hobo/agent/common/models.py +++ b/hobo/agent/common/models.py @@ -6,3 +6,4 @@ class Role(Group): uuid = models.CharField(max_length=32) description = models.TextField(default=u'') details = models.TextField(default=u'') + auth_level = models.PositiveSmallIntegerField(default=1) -- 2.20.1