mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-15 13:36:18 +00:00
gatekeeper and app_gateway first commit
This commit is contained in:
0
app_gateway/__init__.py
Normal file
0
app_gateway/__init__.py
Normal file
1
app_gateway/admin.py
Normal file
1
app_gateway/admin.py
Normal file
@@ -0,0 +1 @@
|
||||
# Register your models here.
|
||||
6
app_gateway/apps.py
Normal file
6
app_gateway/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AppGatewayConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app_gateway'
|
||||
100
app_gateway/migrations/0001_initial.py
Normal file
100
app_gateway/migrations/0001_initial.py
Normal file
@@ -0,0 +1,100 @@
|
||||
# Generated by Django 5.2.12 on 2026-03-11 19:35
|
||||
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('gatekeeper', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Application',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.SlugField(max_length=64, unique=True)),
|
||||
('display_name', models.CharField(max_length=128)),
|
||||
('upstream', models.CharField(help_text='Upstream address, e.g.: http://10.188.18.27:3000', 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)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AccessPolicy',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.SlugField(max_length=64, unique=True)),
|
||||
('policy_type', models.CharField(choices=[('bypass', 'Bypass (public)'), ('one_factor', 'One Factor'), ('two_factor', 'Two Factor'), ('deny', 'Deny')], max_length=32)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('groups', models.ManyToManyField(blank=True, related_name='policies', to='gatekeeper.gatekeepergroup')),
|
||||
('methods', models.ManyToManyField(blank=True, related_name='policies', to='gatekeeper.authmethod')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Access Policy',
|
||||
'verbose_name_plural': 'Access Policies',
|
||||
'ordering': ['name'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationHost',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('hostname', models.CharField(max_length=255, unique=True)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hosts', to='app_gateway.application')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['hostname'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationPolicy',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('application', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='default_policy_config', to='app_gateway.application')),
|
||||
('default_policy', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='application_defaults', to='app_gateway.accesspolicy')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Application Policy',
|
||||
'verbose_name_plural': 'Application Policies',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ApplicationRoute',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.SlugField(help_text='Route identifier, used in export (e.g.: public_area)', max_length=64)),
|
||||
('path_prefix', models.CharField(max_length=255)),
|
||||
('order', models.PositiveIntegerField(default=0, help_text='Evaluation order — lower value means higher priority')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='routes', to='app_gateway.application')),
|
||||
('policy', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='routes', to='app_gateway.accesspolicy')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Application Route',
|
||||
'verbose_name_plural': 'Application Routes',
|
||||
'ordering': ['application', 'order', 'path_prefix'],
|
||||
'unique_together': {('application', 'name'), ('application', 'path_prefix')},
|
||||
},
|
||||
),
|
||||
]
|
||||
0
app_gateway/migrations/__init__.py
Normal file
0
app_gateway/migrations/__init__.py
Normal file
100
app_gateway/models.py
Normal file
100
app_gateway/models.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import uuid
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from gatekeeper.models import GatekeeperGroup, AuthMethod
|
||||
|
||||
|
||||
class Application(models.Model):
|
||||
name = models.SlugField(max_length=64, unique=True)
|
||||
display_name = models.CharField(max_length=128)
|
||||
upstream = models.CharField(max_length=255, help_text=_("Upstream address, e.g.: http://10.188.18.27:3000"))
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.display_name
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
|
||||
|
||||
class ApplicationHost(models.Model):
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='hosts')
|
||||
hostname = models.CharField(max_length=255, unique=True)
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.hostname
|
||||
|
||||
class Meta:
|
||||
ordering = ['hostname']
|
||||
|
||||
|
||||
class AccessPolicy(models.Model):
|
||||
POLICY_TYPE_CHOICES = [
|
||||
('bypass', _('Bypass (public)')),
|
||||
('one_factor', _('One Factor')),
|
||||
('two_factor', _('Two Factor')),
|
||||
('deny', _('Deny')),
|
||||
]
|
||||
|
||||
name = models.SlugField(max_length=64, unique=True)
|
||||
policy_type = models.CharField(max_length=32, choices=POLICY_TYPE_CHOICES)
|
||||
groups = models.ManyToManyField(GatekeeperGroup, blank=True, related_name='policies')
|
||||
methods = models.ManyToManyField(AuthMethod, blank=True, related_name='policies')
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.get_policy_type_display()})"
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
verbose_name = 'Access Policy'
|
||||
verbose_name_plural = 'Access Policies'
|
||||
|
||||
|
||||
class ApplicationPolicy(models.Model):
|
||||
application = models.OneToOneField(Application, on_delete=models.CASCADE, related_name='default_policy_config')
|
||||
default_policy = models.ForeignKey(AccessPolicy, on_delete=models.PROTECT, related_name='application_defaults')
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.application} → default: {self.default_policy}"
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Application Policy'
|
||||
verbose_name_plural = 'Application Policies'
|
||||
|
||||
|
||||
class ApplicationRoute(models.Model):
|
||||
application = models.ForeignKey(Application, on_delete=models.CASCADE, related_name='routes')
|
||||
name = models.SlugField(max_length=64, help_text=_("Route identifier, used in export (e.g.: public_area)"))
|
||||
path_prefix = models.CharField(max_length=255)
|
||||
policy = models.ForeignKey(AccessPolicy, on_delete=models.PROTECT, related_name='routes')
|
||||
order = models.PositiveIntegerField(default=0, help_text=_("Evaluation order — lower value means higher priority"))
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.application} {self.path_prefix} → {self.policy}"
|
||||
|
||||
class Meta:
|
||||
ordering = ['application', 'order', 'path_prefix']
|
||||
unique_together = [('application', 'path_prefix'), ('application', 'name')]
|
||||
verbose_name = 'Application Route'
|
||||
verbose_name_plural = 'Application Routes'
|
||||
1
app_gateway/tests.py
Normal file
1
app_gateway/tests.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your tests here.
|
||||
1
app_gateway/views.py
Normal file
1
app_gateway/views.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user