Skip to content

Commit

Permalink
Add external migration for oauth2 provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Apr 22, 2015
1 parent e9b597f commit 0bca234
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Empty file added dmt/migrations/__init__.py
Empty file.
71 changes: 71 additions & 0 deletions dmt/migrations/provider/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import provider.utils
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='AccessToken',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('token', models.CharField(default=provider.utils.long_token, max_length=255, db_index=True)),
('expires', models.DateTimeField()),
('scope', models.IntegerField(default=2, choices=[(2, b'read'), (4, b'write'), (6, b'read+write')])),
],
),
migrations.CreateModel(
name='Client',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=255, blank=True)),
('url', models.URLField(help_text=b"Your application's URL.")),
('redirect_uri', models.URLField(help_text=b"Your application's callback URL")),
('client_id', models.CharField(default=provider.utils.short_token, max_length=255)),
('client_secret', models.CharField(default=provider.utils.long_token, max_length=255)),
('client_type', models.IntegerField(choices=[(0, b'Confidential (Web applications)'), (1, b'Public (Native and JS applications)')])),
('user', models.ForeignKey(related_name='oauth2_client', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
],
),
migrations.CreateModel(
name='Grant',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('code', models.CharField(default=provider.utils.long_token, max_length=255)),
('expires', models.DateTimeField(default=provider.utils.get_code_expiry)),
('redirect_uri', models.CharField(max_length=255, blank=True)),
('scope', models.IntegerField(default=0)),
('client', models.ForeignKey(to='provider.Client')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='RefreshToken',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('token', models.CharField(default=provider.utils.long_token, max_length=255)),
('expired', models.BooleanField(default=False)),
('access_token', models.OneToOneField(related_name='refresh_token', to='provider.AccessToken')),
('client', models.ForeignKey(to='provider.Client')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='accesstoken',
name='client',
field=models.ForeignKey(to='provider.Client'),
),
migrations.AddField(
model_name='accesstoken',
name='user',
field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
),
]
Empty file.
6 changes: 6 additions & 0 deletions dmt/settings_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,9 @@
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}

PROVIDER_APPLICATION_MODEL = 'provider.Application'

MIGRATION_MODULES = {
'provider': 'dmt.migrations.provider',
}

0 comments on commit 0bca234

Please sign in to comment.