File tree Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1+ .vscode /
12* .pyc
23.idea /
34__pycache__ /
Original file line number Diff line number Diff line change 1414db .init_app (app )
1515
1616"""
17- JWT related configurations began . The following functions includes:
17+ JWT related configuration . The following functions includes:
18181) add claims to each jwt
19192) customize the token expired error message
2020"""
21- app .config ['JWT_SECRET_KEY' ] = 'jose' # we can also use app.secret like before, Flask-JWT-Extended can recognize both
21+ app .config ['JWT_SECRET_KEY' ] = 'jose' # we can also use app.secret like before, Flask-JWT-Extended can recognize both
2222app .config ['JWT_BLACKLIST_ENABLED' ] = True # enable blacklist feature
2323app .config ['JWT_BLACKLIST_TOKEN_CHECKS' ] = ['access' , 'refresh' ] # allow blacklisting for access and refresh tokens
2424jwt = JWTManager (app )
2828and for each jwt protected endpoint, we can retrieve these claims via `get_jwt_claims()`
2929one possible use case for claims are access level control, which is shown below
3030"""
31-
32-
3331@jwt .user_claims_loader
3432def add_claims_to_jwt (identity ):
3533 if identity == 1 : # instead of hard-coding, we can read from a config file to get a list of admins instead
Original file line number Diff line number Diff line change 1+ Flask-JWT-Extended
2+ Flask-RESTful
3+ Flask-SQLAlchemy
4+
You can’t perform that action at this time.
0 commit comments