[img]https://i.sstatic.net /LRvfSzUd.png[/img]
Мой API работает на Flask и имеет следующие настройки:
Код: Выделить всё
# ------------- Flask App -------------
app = Flask(__name__, static_folder='templates/static')
app.secret_key = 'secret'
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SESSION_USE_SIGNER'] = True
app.config['SESSION_PERMANENT'] = False
app.config['SESSION_COOKIE_SECURE'] = True # Nur über HTTPS
app.config['SESSION_COOKIE_HTTPONLY'] = True # Nicht über JavaScript zugänglich
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Schutz vor CSRF
app.config['SESSION_COOKIE_SECURE'] = True
@app.after_request
def add_security_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
# response.headers['Content-Security-Policy'] = "default-src 'self'; img-src 'self'
https://images-na.ssl-images-amazon.com/ https://cdn.discordapp.com/; style-src 'self'
https://unpkg.com/boxicons@2.1.4/css/; font-src 'self' https://unpkg.com/boxicons@2.1.4/;
script-src 'self' 'unsafe-inline' 'unsafe-eval'"
response.headers['Strict-Transport-Security'] = 'max-age=31536000;
includeSubDomains;preload'
response.headers['X-Content-Type-Options'] = 'nosniff'
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
response.headers['Referrer-Policy'] = 'same-origin'
return response
Код: Выделить всё
@app.route('/oauth', methods=['GET'])
def oauth():
# Check if data ok
if membership: # If user is allowed to use App
session['userdata'] = [id, avatar, username, usertag, membership, access_token]
session.setdefault('filter', [None, None, None])
return jsonify({'status': 'authorized'})
Я уже пытался изменить настройки в Flask, как в этом посте: я не могу установить файлы cookie, полученные в ответ, но это ничего не изменило.>
Подробнее здесь: https://stackoverflow.com/questions/784 ... ion-cookie