summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Culver <evan@evanculver.com>2013-10-25 23:14:02 (GMT)
committerEvan Culver <evan@evanculver.com>2013-10-25 23:14:02 (GMT)
commit5113cf5441d76150074881e869e1564ba53646f0 (patch)
treeff75ab1ec7b91b0d9b6a70e1e2fbb1b032c73bc3
parentdcee7bc4c9788d692f5f136a387ad7987193e9e9 (diff)
parent69cd068a911e3b3fd5f82bd5b0620c1ad4625f78 (diff)
downloaddjango-oauth2-provider-5113cf5441d76150074881e869e1564ba53646f0.zip
django-oauth2-provider-5113cf5441d76150074881e869e1564ba53646f0.tar.gz
django-oauth2-provider-5113cf5441d76150074881e869e1564ba53646f0.tar.bz2
Merge pull request #31 from gotche/master
Add index to AccessToken.token
-rw-r--r--provider/oauth2/migrations/0004_auto__add_index_accesstoken_token.py98
-rw-r--r--provider/oauth2/models.py2
2 files changed, 99 insertions, 1 deletions
diff --git a/provider/oauth2/migrations/0004_auto__add_index_accesstoken_token.py b/provider/oauth2/migrations/0004_auto__add_index_accesstoken_token.py
new file mode 100644
index 0000000..9eb6ff6
--- /dev/null
+++ b/provider/oauth2/migrations/0004_auto__add_index_accesstoken_token.py
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding index on 'AccessToken', fields ['token']
+ db.create_index('oauth2_accesstoken', ['token'])
+
+
+ def backwards(self, orm):
+ # Removing index on 'AccessToken', fields ['token']
+ db.delete_index('oauth2_accesstoken', ['token'])
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'oauth2.accesstoken': {
+ 'Meta': {'object_name': 'AccessToken'},
+ 'client': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oauth2.Client']"}),
+ 'expires': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 8, 0, 0)'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'scope': ('django.db.models.fields.IntegerField', [], {'default': '2'}),
+ 'token': ('django.db.models.fields.CharField', [], {'default': "'ab8c8bcd91e8750462b631516b60b0b95dffe1f4'", 'max_length': '255', 'db_index': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'oauth2.client': {
+ 'Meta': {'object_name': 'Client'},
+ 'client_id': ('django.db.models.fields.CharField', [], {'default': "'0a8e54e38c024606ba0a'", 'max_length': '255'}),
+ 'client_secret': ('django.db.models.fields.CharField', [], {'default': "'e53ddb9736f9eea65100885a1b20fb5f2bb0fb4d'", 'max_length': '255'}),
+ 'client_type': ('django.db.models.fields.IntegerField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'redirect_uri': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'oauth2_client'", 'null': 'True', 'to': "orm['auth.User']"})
+ },
+ 'oauth2.grant': {
+ 'Meta': {'object_name': 'Grant'},
+ 'client': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oauth2.Client']"}),
+ 'code': ('django.db.models.fields.CharField', [], {'default': "'5e0ca84e98678a3b55b8901e85a20f995672aea2'", 'max_length': '255'}),
+ 'expires': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 8, 8, 0, 0)'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redirect_uri': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'scope': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'oauth2.refreshtoken': {
+ 'Meta': {'object_name': 'RefreshToken'},
+ 'access_token': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'refresh_token'", 'unique': 'True', 'to': "orm['oauth2.AccessToken']"}),
+ 'client': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oauth2.Client']"}),
+ 'expired': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'token': ('django.db.models.fields.CharField', [], {'default': "'32e9eb7edda764ba8f752ae49223d42acea7cb88'", 'max_length': '255'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ }
+ }
+
+ complete_apps = ['oauth2'] \ No newline at end of file
diff --git a/provider/oauth2/models.py b/provider/oauth2/models.py
index 6894595..d6e6f8a 100644
--- a/provider/oauth2/models.py
+++ b/provider/oauth2/models.py
@@ -102,7 +102,7 @@ class AccessToken(models.Model):
expiry
"""
user = models.ForeignKey(AUTH_USER_MODEL)
- token = models.CharField(max_length=255, default=long_token)
+ token = models.CharField(max_length=255, default=long_token, db_index=True)
client = models.ForeignKey(Client)
expires = models.DateTimeField()
scope = models.IntegerField(default=constants.SCOPES[0][0],