有没有办法使用 basic_auth 获取 python Bottle 中当前经过身份验证的用户的用户名?

Is there a way to get the username of the currently authenticated user in python Bottle using basic_auth?

我想在 python Bottle 会话中显示当前授权的用户,我在其中使用 basic_auth 作为授权框架。有办法吗?

您有两个选择:

user = request.auth[0]

user = request.environ.get('REMOTE_USER')