因為使用restful方式,因此每次用戶訪問都會上傳帶入auth_key,如jwt等,因此可在@app.before_request中做權限的檢查。
@app.app.before_request def before_request(): #可在此處檢查jwt等auth_key是否合法, #abort(401) #然后根據endpoint,檢查此api是否有權限,需要自行處理 #print(["endpoint",connexion.request.url_rule.endpoint]) #abort(401) #也可做ip檢查,以阻擋受限制的ip等