add IP address authentication method and related model

This commit is contained in:
Eduardo Silva
2026-03-12 09:35:27 -03:00
parent e57bce8495
commit 6d129213cd
2 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
# Generated by Django 5.2.12 on 2026-03-12 12:35
import uuid
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('gatekeeper', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='authmethod',
name='auth_type',
field=models.CharField(choices=[('local_password', 'Local Password'), ('totp', 'One-Time Password (TOTP)'), ('oidc', 'OpenID Connect (OIDC)'), ('ip_address', 'IP Address List')], max_length=32),
),
migrations.CreateModel(
name='GatekeeperIPAddress',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('address', models.GenericIPAddressField()),
('prefix_length', models.PositiveSmallIntegerField(blank=True, help_text='CIDR prefix length (e.g.: 24 for /24). Leave blank for a single host.', null=True)),
('action', models.CharField(choices=[('allow', 'Allow'), ('deny', 'Deny')], default='allow', max_length=8)),
('description', models.CharField(blank=True, max_length=255)),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
('auth_method', models.ForeignKey(limit_choices_to={'auth_type': 'ip_address'}, on_delete=django.db.models.deletion.CASCADE, related_name='ip_addresses', to='gatekeeper.authmethod')),
],
options={
'verbose_name': 'IP Address',
'verbose_name_plural': 'IP Addresses',
'ordering': ['address'],
'unique_together': {('auth_method', 'address', 'prefix_length')},
},
),
]