Add nonce to Code model. Modify create_code function.
This commit is contained in:
parent
0de868941a
commit
6dde3a59a8
4 changed files with 24 additions and 2 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
19
oidc_provider/migrations/0003_code_nonce.py
Normal file
19
oidc_provider/migrations/0003_code_nonce.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue