Add nonce to Code model. Modify create_code function.

This commit is contained in:
juanifioren 2015-07-15 16:23:36 -03:00
parent 0de868941a
commit 6dde3a59a8
4 changed files with 24 additions and 2 deletions

View file

@ -96,7 +96,8 @@ class AuthorizeEndpoint(object):
code = create_code(
user=self.request.user,
client=self.client,
scope=self.params.scope)
scope=self.params.scope,
nonce=self.params.nonce)
code.save()

View file

@ -76,7 +76,7 @@ def create_token(user, client, id_token_dic, scope):
return token
def create_code(user, client, scope):
def create_code(user, client, scope, nonce):
"""
Create and populate a Code object.
@ -89,5 +89,6 @@ def create_code(user, client, scope):
code.expires_at = timezone.now() + timedelta(
seconds=settings.get('OIDC_CODE_EXPIRE'))
code.scope = scope
code.nonce = nonce
return code

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('oidc_provider', '0002_userconsent'),
]
operations = [
migrations.AddField(
model_name='code',
name='nonce',
field=models.CharField(default=b'', max_length=255, blank=True),
),
]

View file

@ -71,6 +71,7 @@ class BaseCodeTokenModel(models.Model):
class Code(BaseCodeTokenModel):
code = models.CharField(max_length=255, unique=True)
nonce = models.CharField(max_length=255, blank=True, default='')
class Token(BaseCodeTokenModel):