Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Do not expire AccessTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Mclean committed Aug 22, 2018
1 parent 513d09c commit ecd34d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions api/v2/serializers/details/access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class AccessTokenSerializer(serializers.ModelSerializer):
expireTime = serializers.ReadOnlyField(source='token.expireTime')

class Meta:
model = AccessToken
fields = ('name', 'expireTime', 'id')
fields = ('name', 'id')
2 changes: 0 additions & 2 deletions api/v2/views/access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ def create(self, request):

user = AtmosphereUser.objects.get(id=atmo_user)
access_token = create_access_token(user, name, issuer=issuer_backend)
expireTime = access_token.token.expireTime
json_response = {
'token': access_token.token_id,
'expireTime': expireTime.strftime("%b %d, %Y %H:%M:%S"),
'id': access_token.id,
'name': name
}
Expand Down
9 changes: 3 additions & 6 deletions core/models/access_token.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.db import models
from django.utils import timezone

from django_cyverse_auth.models import Token, get_or_create_token
from django_cyverse_auth.models import Token

from datetime import timedelta

class AccessToken(models.Model):
"""
Expand All @@ -17,9 +16,7 @@ class Meta:
app_label = "core"

def create_access_token(user, token_name=None, token_expire=None, remote_ip=None, issuer=None):
if not token_expire:
token_expire = timezone.now() + timedelta(days=365*5)

token = get_or_create_token(user, None, token_expire, remote_ip, issuer)
token = Token(user=user)
token.save()
access_token, created = AccessToken.objects.update_or_create(token=token, name=token_name)
return access_token

0 comments on commit ecd34d2

Please sign in to comment.