aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tokenauth
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework/tokenauth')
-rw-r--r--djangorestframework/tokenauth/__init__.py0
-rw-r--r--djangorestframework/tokenauth/models.py15
-rw-r--r--djangorestframework/tokenauth/views.py0
3 files changed, 15 insertions, 0 deletions
diff --git a/djangorestframework/tokenauth/__init__.py b/djangorestframework/tokenauth/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/djangorestframework/tokenauth/__init__.py
diff --git a/djangorestframework/tokenauth/models.py b/djangorestframework/tokenauth/models.py
new file mode 100644
index 00000000..f289b0fd
--- /dev/null
+++ b/djangorestframework/tokenauth/models.py
@@ -0,0 +1,15 @@
+import uuid
+from django.db import models
+
+class BasicToken(models.Model):
+ """
+ The default authorization token model class.
+ """
+ key = models.CharField(max_length=32, primary_key=True, blank=True)
+ user = models.ForeignKey('auth.User')
+ revoked = models.BooleanField(default=False)
+
+ def save(self, *args, **kwargs):
+ if not self.key:
+ self.key = uuid.uuid4().hex
+ return super(BasicToken, self).save(*args, **kwargs)
diff --git a/djangorestframework/tokenauth/views.py b/djangorestframework/tokenauth/views.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/djangorestframework/tokenauth/views.py