Skip to content

Commit

Permalink
Merge pull request #76 from katagomo/main
Browse files Browse the repository at this point in the history
Fix #75 增加鉴权字段到缓存键
  • Loading branch information
HisAtri authored Oct 7, 2024
2 parents a689635 + fb1671a commit e3fdbfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@


# 缓存键,解决缓存未忽略参数的情况
def make_cache_key(*args, **kwargs):
path = request.path
args = str(hash(frozenset(request.args.items())))
return path + args
def make_cache_key(*args, **kwargs) -> str:
path:str = request.path
args:str = str(hash(frozenset(request.args.items())))
auth_key:str = str(request.headers.get('Authorization', '')
or request.headers.get('Authentication', ''))
cookie:str = str(request.cookies.get('api_auth_token', ''))
return path + args + auth_key + cookie


def get_base_path():
Expand Down
1 change: 0 additions & 1 deletion api/lyrics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from . import *

import os
import concurrent.futures

from flask import request, abort, jsonify, render_template_string
from urllib.parse import unquote_plus
Expand Down

0 comments on commit e3fdbfe

Please sign in to comment.