Sanic JWT adds authentication protection and endpoints to Sanic.
Pick your favorite user management system, run a single class to initialize, and you are all set.
What is new in Version 1.0?¶
If you have been using Sanic JWT, there should really not be that much different, although under the hood a lot has changed. For starters, the
initialize method still works. But, the new recommended way to start Sanic JWT is to use the new
Initialize class as seen above.
Using this class allows you to subclass it and really dive deep into modifying and configuring your project just the way you need it. Want to change the authentication responses? No problem. Want to add some new authentication endpoints? Easy.
One of the bigger changes is that we have enabled a new way to add configuration settings. You can of course continue to set them as recommended by Sanic by making them in all capital letters, and giving it a
app.config.SANIC_JWT_ACCESS_TOKEN_NAME = 'mytoken'
Or, you can simply pass your configurations into the
Initialize class as keyword arguments.
Initialize( app, access_token_name='mytoken' )
Do you need some more complicated logic, or control? Then perhaps you want to subclass the
class MyConfig(Configuration): access_token_name='mytoken' def get_refresh_token_name(self): return some_crazy_logic_to_get_token_name() Initialize( app, configuration_class=MyConfig )
The point is, with Version 1, we made the entire package extremely adaptable and extensible for you to get done what you need without making decisions for you.
Have fun, and happy coding.