from flask import Flask
from flask_cors import CORS
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from flask_jwt_extended import JWTManager


app = Flask(__name__)
CORS(app)
api = Api(app)


app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'some-secret-string'
app.config['JWT_SECRET_KEY'] = 'jwt-secret-string'
app.config['JWT_BLACKLIST_ENABLED'] = True
app.config['JWT_BLACKLIST_TOKEN_CHECKS'] = ['access', 'refresh']


db = SQLAlchemy(app)
jwt = JWTManager(app)


@app.before_first_request
def create_tables():
    db.create_all()


import models, resources, views


api.add_resource(resources.UserRegistration, '/registration')
api.add_resource(resources.UserLogin, '/login')
api.add_resource(resources.UserLogoutAccess, '/logout/access')
api.add_resource(resources.UserLogoutRefresh, '/logout/refresh')
api.add_resource(resources.TokenRefresh, '/token/refresh')
api.add_resource(resources.AllUsers, '/users')
api.add_resource(resources.SecretResource, '/secret')


@jwt.token_in_blacklist_loader
def check_if_token_in_blacklist(decrypted_token):
    jti = decrypted_token['jti']
    return models.RevokedTokenModel.is_jti_blacklisted(jti)
[((8, 6, 8, 21), 'flask.Flask', 'Flask', ({(8, 12, 8, 20): '__name__'}, {}), '(__name__)', False, 'from flask import Flask\n'), ((9, 0, 9, 9), 'flask_cors.CORS', 'CORS', ({(9, 5, 9, 8): 'app'}, {}), '(app)', False, 'from flask_cors import CORS\n'), ((10, 6, 10, 14), 'flask_restful.Api', 'Api', ({(10, 10, 10, 13): 'app'}, {}), '(app)', False, 'from flask_restful import Api\n'), ((21, 5, 21, 20), 'flask_sqlalchemy.SQLAlchemy', 'SQLAlchemy', ({(21, 16, 21, 19): 'app'}, {}), '(app)', False, 'from flask_sqlalchemy import SQLAlchemy\n'), ((22, 6, 22, 21), 'flask_jwt_extended.JWTManager', 'JWTManager', ({(22, 17, 22, 20): 'app'}, {}), '(app)', False, 'from flask_jwt_extended import JWTManager\n'), ((45, 11, 45, 59), 'models.RevokedTokenModel.is_jti_blacklisted', 'models.RevokedTokenModel.is_jti_blacklisted', ({(45, 55, 45, 58): 'jti'}, {}), '(jti)', False, 'import models, resources, views\n')]