Commit 290701e0 authored by Valentin Samir's avatar Valentin Samir

Changes for Django 2.0 support

parent fcafc77b
Pipeline #718 canceled with stage
...@@ -11,6 +11,10 @@ matrix: ...@@ -11,6 +11,10 @@ matrix:
env: TOX_ENV=py35-django111 env: TOX_ENV=py35-django111
- python: "3.6" - python: "3.6"
env: TOX_ENV=py36-django111 env: TOX_ENV=py36-django111
- python: "3.5"
env: TOX_ENV=py35-django20
- python: "3.6"
env: TOX_ENV=py36-django20
- python: "2.7" - python: "2.7"
env: TOX_ENV=coverage env: TOX_ENV=coverage
cache: cache:
......
...@@ -16,7 +16,7 @@ Added ...@@ -16,7 +16,7 @@ Added
* Support for Django 2.0 * Support for Django 2.0
Fixes Fixes
---- -----
* Add missing attributes authenticationDate, longTermAuthenticationRequestTokenUsed and * Add missing attributes authenticationDate, longTermAuthenticationRequestTokenUsed and
isFromNewLogin from service validation response isFromNewLogin from service validation response
...@@ -31,6 +31,12 @@ Deprecated ...@@ -31,6 +31,12 @@ Deprecated
* Support for python 3.4 is dropped, it should still works for this version. * Support for python 3.4 is dropped, it should still works for this version.
Next versions may or may not works with python 3.4. Next versions may or may not works with python 3.4.
Other
-----
* Migrations have been squashed for Django 2.0 support. Be sur to apply all migration before
updating to this version
v0.9.0 - 2017-11-17 v0.9.0 - 2017-11-17
=================== ===================
......
...@@ -37,8 +37,8 @@ dist: ...@@ -37,8 +37,8 @@ dist:
python setup.py sdist python setup.py sdist
test_venv/bin/python: test_venv/bin/python:
virtualenv test_venv python3 -m venv test_venv
test_venv/bin/pip install -U --requirement requirements-dev.txt 'Django<1.11' test_venv/bin/pip install -U --requirement requirements-dev.txt 'Django>=2.0,<2.1'
test_venv/cas/manage.py: test_venv test_venv/cas/manage.py: test_venv
mkdir -p test_venv/cas mkdir -p test_venv/cas
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0001_squashed_0021_auto_20150611_2102'),
]
operations = [
migrations.AlterField(
model_name='user',
name='date',
field=models.DateTimeField(auto_now=True),
preserve_default=True,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0002_auto_20151212_1300'),
]
operations = [
migrations.AlterField(
model_name='servicepattern',
name='pattern',
field=models.CharField(help_text="A regular expression matching services. Will usually looks like '^https://some\\.server\\.com/path/.*$'.As it is a regular expression, special character must be escaped with a '\\'.", unique=True, max_length=255, verbose_name='pattern'),
preserve_default=True,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0003_auto_20151212_1721'),
]
operations = [
migrations.AlterModelOptions(
name='servicepattern',
options={'ordering': ('pos',), 'verbose_name': 'Service pattern', 'verbose_name_plural': 'Services patterns'},
),
migrations.AlterModelOptions(
name='user',
options={'verbose_name': 'User', 'verbose_name_plural': 'Users'},
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-16 10:18
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0004_auto_20151218_1032'),
]
operations = [
migrations.AlterField(
model_name='servicepattern',
name='pos',
field=models.IntegerField(default=100, help_text='service patterns are sorted using the position attribute', verbose_name='position'),
),
migrations.CreateModel(
name='FederatedIendityProvider',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('suffix', models.CharField(help_text='Suffix append to backend CAS returner username: `returned_username`@`suffix`', max_length=30, unique=True, verbose_name='suffix')),
('server_url', models.CharField(max_length=255, verbose_name='server url')),
('cas_protocol_version', models.CharField(choices=[(b'1', b'CAS 1.0'), (b'2', b'CAS 2.0'), (b'3', b'CAS 3.0'), (b'CAS_2_SAML_1_0', b'SAML 1.1')], default=b'3', help_text='Version of the CAS protocol to use when sending requests the the backend CAS', max_length=30, verbose_name='CAS protocol version')),
('verbose_name', models.CharField(help_text='Name for this identity provider displayed on the login page', max_length=255, verbose_name='verbose name')),
('pos', models.IntegerField(default=100, help_text='Identity provider are sorted using the (position, verbose name, suffix) attributes', verbose_name='position')),
('display', models.BooleanField(default=True, help_text='Display the provider on the login page', verbose_name='display')),
],
options={
'verbose_name': 'identity provider',
'verbose_name_plural': 'identity providers',
},
),
migrations.CreateModel(
name='FederatedUser',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=124)),
('provider', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cas_server.FederatedIendityProvider')),
('attributs', models.TextField(blank=True, default=None, null=True)),
('ticket', models.CharField(max_length=255)),
('last_update', models.DateTimeField(auto_now=True)),
],
),
migrations.AlterUniqueTogether(
name='federateduser',
unique_together=set([('username', 'provider')]),
),
migrations.CreateModel(
name='FederateSLO',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=30)),
('session_key', models.CharField(blank=True, max_length=40, null=True)),
('ticket', models.CharField(db_index=True, max_length=255)),
],
),
migrations.AlterUniqueTogether(
name='federateslo',
unique_together=set([('username', 'session_key', 'ticket')]),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-06 17:27
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0005_auto_20160616_1018'),
]
operations = [
migrations.AlterField(
model_name='federatediendityprovider',
name='cas_protocol_version',
field=models.CharField(choices=[(b'1', b'CAS 1.0'), (b'2', b'CAS 2.0'), (b'3', b'CAS 3.0'), (b'CAS_2_SAML_1_0', b'SAML 1.1')], default=b'3', help_text='Version of the CAS protocol to use when sending requests the the backend CAS.', max_length=30, verbose_name='CAS protocol version'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='display',
field=models.BooleanField(default=True, help_text='Display the provider on the login page.', verbose_name='display'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='pos',
field=models.IntegerField(default=100, help_text='Position of the identity provider on the login page. Identity provider are sorted using the (position, verbose name, suffix) attributes.', verbose_name='position'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='suffix',
field=models.CharField(help_text='Suffix append to backend CAS returner username: ``returned_username`` @ ``suffix``.', max_length=30, unique=True, verbose_name='suffix'),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='verbose_name',
field=models.CharField(help_text='Name for this identity provider displayed on the login page.', max_length=255, verbose_name='verbose name'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-07-23 22:52
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0006_auto_20160706_1727'),
]
operations = [
migrations.RemoveField(
model_name='federateduser',
name='attributs',
),
migrations.RemoveField(
model_name='proxygrantingticket',
name='attributs',
),
migrations.RemoveField(
model_name='proxyticket',
name='attributs',
),
migrations.RemoveField(
model_name='serviceticket',
name='attributs',
),
migrations.AddField(
model_name='federateduser',
name='_attributs',
field=models.TextField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='proxygrantingticket',
name='_attributs',
field=models.TextField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='proxyticket',
name='_attributs',
field=models.TextField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='serviceticket',
name='_attributs',
field=models.TextField(blank=True, default=None, null=True),
),
migrations.AlterField(
model_name='federatediendityprovider',
name='suffix',
field=models.CharField(help_text='Suffix append to backend CAS returned username: ``returned_username`` @ ``suffix``.', max_length=30, unique=True, verbose_name='suffix'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-27 21:59
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0007_auto_20160723_2252'),
]
operations = [
migrations.CreateModel(
name='NewVersionWarning',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.CharField(max_length=255)),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-08-14 06:19
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0008_newversionwarning'),
]
operations = [
migrations.AlterField(
model_name='filterattributvalue',
name='attribut',
field=models.CharField(help_text='Name of the attribute which must verify pattern', max_length=255, verbose_name='attribute'),
),
migrations.AlterField(
model_name='replaceattributname',
name='name',
field=models.CharField(help_text='name of an attribute to send to the service, use * for all attributes', max_length=255, verbose_name='name'),
),
migrations.AlterField(
model_name='replaceattributname',
name='replace',
field=models.CharField(blank=True, help_text='name under which the attribute will be showto the service. empty = default name of the attribut', max_length=255, verbose_name='replace'),
),
migrations.AlterField(
model_name='replaceattributvalue',
name='attribut',
field=models.CharField(help_text='Name of the attribute for which the value must be replace', max_length=255, verbose_name='attribute'),
),
migrations.AlterField(
model_name='servicepattern',
name='user_field',
field=models.CharField(blank=True, default=b'', help_text='Name of the attribute to transmit as username, empty = login', max_length=255, verbose_name='user field'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-24 21:12
from __future__ import unicode_literals
import cas_server.utils
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0009_auto_20160814_0619'),
]
operations = [
migrations.AlterField(
model_name='filterattributvalue',
name='pattern',
field=models.CharField(help_text='a regular expression', max_length=255, validators=[cas_server.utils.regexpr_validator], verbose_name='pattern'),
),
migrations.AlterField(
model_name='replaceattributname',
name='replace',
field=models.CharField(blank=True, help_text='name under which the attribute will be show to the service. empty = default name of the attribut', max_length=255, verbose_name='replace'),
),
migrations.AlterField(
model_name='replaceattributvalue',
name='pattern',
field=models.CharField(help_text='An regular expression maching whats need to be replaced', max_length=255, validators=[cas_server.utils.regexpr_validator], verbose_name='pattern'),
),
migrations.AlterField(
model_name='servicepattern',
name='pattern',
field=models.CharField(help_text="A regular expression matching services. Will usually looks like '^https://some\\.server\\.com/path/.*$'.As it is a regular expression, special character must be escaped with a '\\'.", max_length=255, unique=True, validators=[cas_server.utils.regexpr_validator], verbose_name='pattern'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2016-10-07 12:58
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0010_auto_20160824_2112'),
]
operations = [
migrations.CreateModel(
name='UserAttributes',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('_attributs', models.TextField(blank=True, default=None, null=True)),
('username', models.CharField(max_length=155, unique=True)),
],
options={
'verbose_name': 'User attributes cache',
'verbose_name_plural': 'User attributes caches',
},
),
migrations.AlterModelOptions(
name='federateduser',
options={'verbose_name': 'Federated user', 'verbose_name_plural': 'Federated users'},
),
migrations.AddField(
model_name='user',
name='last_login',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-28 14:10
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0011_auto_20161007_1258'),
]
operations = [
migrations.AlterField(
model_name='federatediendityprovider',
name='cas_protocol_version',
field=models.CharField(choices=[('1', 'CAS 1.0'), ('2', 'CAS 2.0'), ('3', 'CAS 3.0'), ('CAS_2_SAML_1_0', 'SAML 1.1')], default='3', help_text='Version of the CAS protocol to use when sending requests the the backend CAS.', max_length=30, verbose_name='CAS protocol version'),
),
migrations.AlterField(
model_name='servicepattern',
name='single_log_out_callback',
field=models.CharField(blank=True, default='', help_text='URL where the SLO request will be POST. empty = service url\nThis is usefull for non HTTP proxied services.', max_length=255, verbose_name='single log out callback'),
),
migrations.AlterField(
model_name='servicepattern',
name='user_field',
field=models.CharField(blank=True, default='', help_text='Name of the attribute to transmit as username, empty = login', max_length=255, verbose_name='user field'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-29 15:48
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cas_server', '0012_auto_20170328_1610'),
]
operations = [
migrations.AlterField(
model_name='user',
name='username',
field=models.CharField(max_length=250),
),
]
...@@ -641,7 +641,7 @@ class Username(models.Model): ...@@ -641,7 +641,7 @@ class Username(models.Model):
#: ForeignKey to a :class:`ServicePattern`. :class:`Username` instances for a #: ForeignKey to a :class:`ServicePattern`. :class:`Username` instances for a
#: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.usernames` #: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.usernames`
#: attribute. #: attribute.
service_pattern = models.ForeignKey(ServicePattern, related_name="usernames") service_pattern = models.ForeignKey(ServicePattern, related_name="usernames", on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return self.value return self.value
...@@ -676,7 +676,7 @@ class ReplaceAttributName(models.Model): ...@@ -676,7 +676,7 @@ class ReplaceAttributName(models.Model):
#: ForeignKey to a :class:`ServicePattern`. :class:`ReplaceAttributName` instances for a #: ForeignKey to a :class:`ServicePattern`. :class:`ReplaceAttributName` instances for a
#: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.attributs` #: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.attributs`
#: attribute. #: attribute.
service_pattern = models.ForeignKey(ServicePattern, related_name="attributs") service_pattern = models.ForeignKey(ServicePattern, related_name="attributs", on_delete=models.CASCADE)
def __str__(self): def __str__(self):
if not self.replace: if not self.replace:
...@@ -711,7 +711,7 @@ class FilterAttributValue(models.Model): ...@@ -711,7 +711,7 @@ class FilterAttributValue(models.Model):
#: ForeignKey to a :class:`ServicePattern`. :class:`FilterAttributValue` instances for a #: ForeignKey to a :class:`ServicePattern`. :class:`FilterAttributValue` instances for a
#: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.filters` #: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.filters`
#: attribute. #: attribute.
service_pattern = models.ForeignKey(ServicePattern, related_name="filters") service_pattern = models.ForeignKey(ServicePattern, related_name="filters", on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return u"%s %s" % (self.attribut, self.pattern) return u"%s %s" % (self.attribut, self.pattern)
...@@ -748,7 +748,7 @@ class ReplaceAttributValue(models.Model): ...@@ -748,7 +748,7 @@ class ReplaceAttributValue(models.Model):
#: ForeignKey to a :class:`ServicePattern`. :class:`ReplaceAttributValue` instances for a #: ForeignKey to a :class:`ServicePattern`. :class:`ReplaceAttributValue` instances for a
#: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.replacements` #: :class:`ServicePattern` are accessible thought its :attr:`ServicePattern.replacements`
#: attribute. #: attribute.
service_pattern = models.ForeignKey(ServicePattern, related_name="replacements") service_pattern = models.ForeignKey(ServicePattern, related_name="replacements", on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return u"%s %s %s" % (self.attribut, self.pattern, self.replace) return u"%s %s %s" % (self.attribut, self.pattern, self.replace)
...@@ -764,14 +764,14 @@ class Ticket(JsonAttributes): ...@@ -764,14 +764,14 @@ class Ticket(JsonAttributes):
class Meta: class Meta:
abstract = True abstract = True
#: ForeignKey to a :class:`User`. #: ForeignKey to a :class:`User`.
user = models.ForeignKey(User, related_name="%(class)s") user = models.ForeignKey(User, related_name="%(class)s", on_delete=models.CASCADE)
#: A boolean. ``True`` if the ticket has been validated #: A boolean. ``True`` if the ticket has been validated
validate = models.BooleanField(default=False) validate = models.BooleanField(default=False)
#: The service url for the ticket #: The service url for the ticket
service = models.TextField() service = models.TextField()
#: ForeignKey to a :class:`ServicePattern`. The :class:`ServicePattern` corresponding to #: ForeignKey to a :class:`ServicePattern`. The :class:`ServicePattern` corresponding to
#: :attr:`service`. Use :meth:`ServicePattern.validate` to find it. #: :attr:`service`. Use :meth:`ServicePattern.validate` to find it.
service_pattern = models.ForeignKey(ServicePattern, related_name="%(class)s") service_pattern = models.ForeignKey(ServicePattern, related_name="%(class)s", on_delete=models.CASCADE)
#: Date of the ticket creation #: Date of the ticket creation
creation = models.DateTimeField(auto_now_add=True) creation = models.DateTimeField(auto_now_add=True)
#: A boolean. ``True`` if the user has just renew his authentication #: A boolean. ``True`` if the user has just renew his authentication
...@@ -1034,7 +1034,7 @@ class Proxy(models.Model): ...@@ -1034,7 +1034,7 @@ class Proxy(models.Model):
#: ForeignKey to a :class:`ProxyTicket`. :class:`Proxy` instances for a #: ForeignKey to a :class:`ProxyTicket`. :class:`Proxy` instances for a
#: :class:`ProxyTicket` are accessible thought its :attr:`ProxyTicket.proxies` #: :class:`ProxyTicket` are accessible thought its :attr:`ProxyTicket.proxies`
#: attribute. #: attribute.
proxy_ticket = models.ForeignKey(ProxyTicket, related_name="proxies") proxy_ticket = models.ForeignKey(ProxyTicket, related_name="proxies", on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return self.url return self.url
......
...@@ -46,7 +46,6 @@ MIDDLEWARE = [ ...@@ -46,7 +46,6 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptions