Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Conversation

erichaus
Copy link

Builds off work submitted by @avimeir and the discussion at #89

@erichaus
Copy link
Author

Tested this in a local project by logging into my app with a distant expiring JWT_EXPIRATION_DATE, issuing a POST to /api/v1/auth-token-blacklist/ with the token, and then attempting to access the api (navigated to another page with api call). A 401 Unauthorized is issued and I am logged out of my ember app as expected... Let me know if anyone has input.. seems like nice feature

@erichaus
Copy link
Author

Should this package include an admin.py for the default black list token implementation? Should the JWTBlackListToken model include any other fields like the actual token value?

@avimeir
Copy link

avimeir commented Mar 28, 2015

@erichonkanen nice work!

I'd add the exp claim to the model, so that we can later clean-up the DB by removing all expired tokens.

@erichaus
Copy link
Author

@avimeir thanks! should the exp be a DateTimeField or CharField? I know the format it comes in as is seconds since epoch

@erichaus
Copy link
Author

def jwt_blacklist_set_handler(payload):
    """
    Default implementation that blacklists a jwt token.
    """
    jti = payload.get('jti')
    exp = datetime.fromtimestamp(payload.get('exp'))

    return models.JWTBlackListToken.objects.create(jti=jti, expires_at=exp)

Made it DateTimeField and just converted

@erichaus
Copy link
Author

erichaus commented May 4, 2015

@jpadilla ran git rebase, fixed conflicts but Im noticing this effectively made a 2nd copy of every commit now at the front.. is this expected or did I do it wrong? Ive mostly just used rebase to squash commits in the past...

@jpadilla
Copy link
Owner

jpadilla commented May 4, 2015

@erichonkanen oh snap, could you perhaps squash all of this into one commit then?

@erichaus
Copy link
Author

erichaus commented May 5, 2015

Cleaned commit history and submitted in new PR

@erichaus erichaus closed this May 5, 2015
@erichaus erichaus deleted the jti branch May 5, 2015 18:38
@uber1geek
Copy link

How can i implement this feature @erichonkanen ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants