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

Adds blacklist token feature as separate subapp #91

Closed
wants to merge 99 commits into from
Closed

Adds blacklist token feature as separate subapp #91

wants to merge 99 commits into from

Conversation

hoIIer
Copy link
Contributor

@hoIIer hoIIer commented Mar 27, 2015

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

@hoIIer
Copy link
Contributor Author

hoIIer commented Mar 28, 2015

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

@hoIIer
Copy link
Contributor Author

hoIIer commented Mar 28, 2015

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.

@hoIIer
Copy link
Contributor Author

hoIIer commented Mar 28, 2015

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

@hoIIer
Copy link
Contributor Author

hoIIer commented Mar 28, 2015

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

@hoIIer
Copy link
Contributor Author

hoIIer 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?

@hoIIer
Copy link
Contributor Author

hoIIer commented May 5, 2015

Cleaned commit history and submitted in new PR

@hoIIer hoIIer closed this May 5, 2015
@hoIIer hoIIer 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