Skip to content

Verify Serializer Should Honour Blacklist#239

Merged
Andrew-Chen-Wang merged 7 commits intojazzband:masterfrom
TeresaSiegmantel:blacklisted_token_should_not_verify
Jul 7, 2021
Merged

Verify Serializer Should Honour Blacklist#239
Andrew-Chen-Wang merged 7 commits intojazzband:masterfrom
TeresaSiegmantel:blacklisted_token_should_not_verify

Conversation

@TeresaSiegmantel
Copy link
Copy Markdown
Contributor

@TeresaSiegmantel TeresaSiegmantel commented Apr 16, 2020

With this patch, the TokenVerifySerializer checks the blacklist if the app is installed.

See Issue #231.

Copy link
Copy Markdown
Member

@Andrew-Chen-Wang Andrew-Chen-Wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Left my review of your PR. Please resolve each comment as you make those changes. Sorry for taking so long @philipp-siegmantel Just getting exponentially busier with college comin' up.

I think from a security standpoint, it looks fine. You can see the description for the token type is:
https://github.com/SimpleJWT/django-rest-framework-simplejwt/blob/master/rest_framework_simplejwt/tokens.py#L299-L303

Untyped tokens do not verify the "token_type" claim.  This is useful
        when performing general validation of a token's signature and other
        properties which do not relate to the token's intended use.

I think only L158 is a concern. I'll leave another comment for that, but basically, you don't want to let someone know that it's blacklisted.

Comment thread tests/test_token_blacklist.py Outdated
Comment thread tests/test_token_blacklist.py Outdated
Comment thread rest_framework_simplejwt/serializers.py Outdated
Comment thread rest_framework_simplejwt/serializers.py Outdated
Comment thread rest_framework_simplejwt/serializers.py Outdated
Comment thread rest_framework_simplejwt/serializers.py Outdated
@Andrew-Chen-Wang
Copy link
Copy Markdown
Member

Closes #231

Hopefully that links with the issue so that the issue automatically closes.

@TeresaSiegmantel
Copy link
Copy Markdown
Contributor Author

TeresaSiegmantel commented Jul 9, 2020

I add your suggestions, thanks for them.

Now I have a problem I can't seem to fix. The test checks that the blacklisted token does not verify, fails. This is due to the RefreshToken constructor throwing a InvalidToken exception. I can't figure out how a freshly created Token for a valid user could not properly verify. Any hints?

Copy link
Copy Markdown
Member

@Andrew-Chen-Wang Andrew-Chen-Wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might've used the wrong name for settings. @philipp-siegmantel

Comment thread tests/test_token_blacklist.py Outdated
Comment thread tests/test_token_blacklist.py Outdated
@Andrew-Chen-Wang
Copy link
Copy Markdown
Member

Quick question: would it be better if we had Travis? Would probably make reviewing PRs and seeing where tests failed easier since it's embedded into the GH site.

@TeresaSiegmantel
Copy link
Copy Markdown
Contributor Author

Ok, now all tests pass.

An attacker could still infer that a token is an access token, but only if it is blacklisted, so I see no problem.

@TeresaSiegmantel
Copy link
Copy Markdown
Contributor Author

TeresaSiegmantel commented Jul 10, 2020

I think some form of CI would be great. Github has Actions, witch are pretty simple to set up.

EDIT: I see you use CircleCI.

@Andrew-Chen-Wang
Copy link
Copy Markdown
Member

Github has Actions, witch are pretty simple to set up. I see you use CircleCI.

Yea, not a fan of CircleCI; that was here before I started using GitHub. I like GitHub actions for CI/CD when it comes to testing certain things and publishing/deployment (e.g. AWS services testing without Moto and AWS deployment). But Travis CI has a nicer interface, especially for open source projects because the builds are individualized via the TOXENV. Additionally, testing the configuration of .travis.yml is a little more smooth and visibly more appealing.

Some great things about GitHub actions are like if a certain path has a file change, then execute an action, whereas Travis doesn't support that.

An attacker could still infer that a token is an access token, but only if it is blacklisted, so I see no problem.

Perhaps with certain configurations. Not too big of a problem for most Django websites since an attacker is not going to know some random website.

@Andrew-Chen-Wang Andrew-Chen-Wang added this to the 5.0.0 milestone Aug 14, 2020
@HodaSadatJafari
Copy link
Copy Markdown

Hi guys
When is this going to be merged?

@Andrew-Chen-Wang
Copy link
Copy Markdown
Member

@auvipy do you mind reviewing this as well? I was waiting for David for a second opinion, but obviously he's absent now.

@Andrew-Chen-Wang Andrew-Chen-Wang requested a review from auvipy April 6, 2021 21:47
Copy link
Copy Markdown
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/changelog should be updated as well



class TokenVerifySerializerShouldHonourBlacklist(MigrationTestCase):
migrate_from = ('token_blacklist', '0002_outstandingtoken_jti_hex')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is testing migration but the PR is not showing any migration changes, or it was already done but not tested?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andrew-Chen-Wang Andrew-Chen-Wang merged commit 19ab467 into jazzband:master Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants