Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOP callbacks #335

Closed
wants to merge 2 commits into from
Closed

OOP callbacks #335

wants to merge 2 commits into from

Conversation

torotil
Copy link

@torotil torotil commented Jun 15, 2020

Here is an attempt to implement #333 .

The first commit is the minimal change needed. The second commit turns things completely around and makes all the default implementations static methods of a class that can be inherited.

I’m still a bit unhappy about the method names and open for suggestions.

Other improvements that came to my mind when I was working on this:

  • Completely merge the default implementations into the JWTManager class, because … why not?
  • JWTManager.token_is_blacklisted() could get a default implementation that always returns False then we could remove has_token_in_blacklist_callback().

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling c2b1197 on moreonion:oop-callbacks into 4a1278c on vimalloc:4.0.0-dev.

@vimalloc-mavenlink
Copy link
Contributor

Thanks for putting this together! I'll take a closer look later, but wanted to reply to a couple things here real quick.

Completely merge the default implementations into the JWTManager class, because … why not?

I think that's a great idea!

JWTManager.token_is_blacklisted() could get a default implementation that always returns False then we could remove has_token_in_blacklist_callback().

I think the current reason we have it setup that ways is so that we can do some checks and raise an error if token revoking is enabled but no callback method was defined:

    if not config.blacklist_enabled:
        return
    if not has_token_in_blacklist_callback():
        raise RuntimeError(
            "A token_in_blacklist_callback must be provided via "
            "the '@token_in_blacklist_loader' if "
            "JWT_BLACKLIST_ENABLED is True"
        )

However, now might be a good time to get rid of the JWT_BLACKLIST_ENABLED configuration option all together and have it be purely based on the callback function which now has a default return value of False

@vimalloc vimalloc closed this Mar 9, 2021
@vimalloc vimalloc deleted the branch vimalloc:4.0.0-dev March 9, 2021 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants