Commit 859bb780 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Add upstream client type

parent d78c7809
......@@ -42,7 +42,7 @@ class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = User
fields = UserCreationForm.Meta.fields + (
'user_type',
'user_type', 'idp',
)
......@@ -57,4 +57,8 @@ class CustomUserAdmin(UserAdmin):
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser',)}),
('Important dates', {'fields': ('last_login', 'date_joined')}),
)
add_fieldsets = ((None, {'fields': ('user_type',)}),) + UserAdmin.add_fieldsets
add_fieldsets = (
(None, {'fields': ('user_type',)}),
) + UserAdmin.add_fieldsets + (
('Upstream User fields', {'fields': ('idp',)}),
)
# Generated by Django 2.2.7 on 2020-01-30 14:28
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('backend', '0012_auto_20200124_1403'),
]
operations = [
migrations.AlterField(
model_name='user',
name='idp',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='users', to='backend.OIDCConfig'),
),
migrations.AlterField(
model_name='user',
name='user_type',
field=models.CharField(choices=[('apiclient', 'Downstream Client'), ('oidcuser', 'Webpage User'), ('admin', 'Admin'), ('upstream', 'Upstream Client')], default='apiclient', max_length=20),
),
]
......@@ -25,9 +25,10 @@ class User(AbstractUser):
USER_ALREADY_EXISTS = Exception('The user does already exist. This usually implies that the IdP changed the sub. Only possible fix: delete the old user')
TYPE_CHOICES = (
('apiclient', 'API-Client'),
('oidcuser', 'OIDC User'),
('admin', 'Admin'),
('apiclient', 'Downstream Client'), # clients which connect to us via pubsub
('oidcuser', 'Webpage User'), # normal users which logged in using the webpage
('admin', 'Admin'), # admins of the django admin
('upstream', 'Upstream Client'), # E.g. an idP that provides us with fresh userinfos or access tokens
)
user_type = models.CharField(
max_length=20,
......@@ -58,7 +59,7 @@ class User(AbstractUser):
on_delete=models.CASCADE,
blank=True,
null=True,
editable=False,
editable=True, # editable because when user_type==upstream the idp needs to be configurable in the admin
)
userinfo = JSONField(
default=user_info_default,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment