core: add uuid to user, use as sub for OpenID

This commit is contained in:
Jens Langhammer 2018-12-09 21:05:25 +01:00
parent 1ab445ab8e
commit af3df16b90
No known key found for this signature in database
GPG Key ID: BEBC05297D92821B
3 changed files with 23 additions and 1 deletions

View File

@ -12,7 +12,7 @@ class OpenIDUserInfoView(ScopedResourceMixin, View):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
"""Passbook v1 OpenID API""" """Passbook v1 OpenID API"""
payload = { payload = {
'sub': request.user.pk, 'sub': request.user.uuid.int,
'name': request.user.get_full_name(), 'name': request.user.get_full_name(),
'given_name': request.user.first_name, 'given_name': request.user.first_name,
'family_name': request.user.last_name, 'family_name': request.user.last_name,

View File

@ -0,0 +1,20 @@
# Generated by Django 2.1.4 on 2018-12-09 17:58
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_core', '0005_auto_20181127_1522'),
]
operations = [
migrations.AddField(
model_name='user',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
]

View File

@ -1,6 +1,7 @@
"""passbook core models""" """passbook core models"""
import re import re
from logging import getLogger from logging import getLogger
from uuid import uuid4
import reversion import reversion
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
@ -16,6 +17,7 @@ LOGGER = getLogger(__name__)
class User(AbstractUser): class User(AbstractUser):
"""Custom User model to allow easier adding o f user-based settings""" """Custom User model to allow easier adding o f user-based settings"""
uuid = models.UUIDField(default=uuid4, editable=False)
sources = models.ManyToManyField('Source', through='UserSourceConnection') sources = models.ManyToManyField('Source', through='UserSourceConnection')
applications = models.ManyToManyField('Application') applications = models.ManyToManyField('Application')