【问题标题】:How to secure password in a flasks server application?如何保护烧瓶服务器应用程序中的密码?
【发布时间】:2020-06-23 00:57:41
【问题描述】:

我有一个简单的烧瓶服务器,它捕获 json webhook,然后登录并将它们发布到内部应用程序中。问题是我需要让服务器在线并暴露。内部应用程序需要登录并公开登录信息。我正在努力寻找隐藏或保护这些信息的最佳方式。

from flask import Flask, request, abort
import xmlrpc.client


app = Flask(__name__)


# Tells the server what route and method to use
@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':



# Logs in to  server
        url = ""
        db = " "
        username = "  "
        password = " "

【问题讨论】:

标签: python flask


【解决方案1】:

你见过bcrypt 包吗?您可以使用它来散列和验证密码

这是他们文档中的一个示例:

>>> import bcrypt
>>> password = b"super secret password"
>>> # Hash a password for the first time, with a randomly-generated salt
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt())
>>> # Check that an unhashed password matches one that has previously been
>>> # hashed
>>> if bcrypt.checkpw(password, hashed):
...     print("It Matches!")
... else:
...     print("It Does not Match :(")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 2016-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多