- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在运行一个 Flask 应用程序,将 apache 与 mod_wsgi 一起使用,使用我自己的 ssl 证书(自签名),我还使用 Flask-HTTPAuth 库(https://flask-httpauth.readthedocs.org/en/latest/)并且我确实使用 BasicAuth
app.auth = HTTPBasicAuth()
我正在尝试使用 curl 测试 api,但我的 flask 应用程序没有让我登录。
这是 curl 线
/usr/bin/curl -H 'Accept: application/json' -H 'Content-type: application/json' -u 'user:mypasswd' --cacert path_to/rootCA.crt --key path_to/backend.key --cert path_to/backend.crt -X POST -d '{}' -vvv https://my_url:443/api/1.0/code/create
服务器有响应
* Hostname was NOT found in DNS cache
* Trying ** ...
* Connected to ** (**) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: path_to/rootCA.crt
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
* subject: ***
* start date: 2015-10-20 13:22:20 GMT
* expire date: 2017-03-03 13:22:20 GMT
* common name: *** (matched)
* issuer: ***
* SSL certificate verify ok.
* Server auth using Basic with user 'user'
> POST //api/1.0/code/create HTTP/1.1
> Authorization: Basic amFtZXM6TDMgbDFuZCEgQHYgczBsMyFM
> User-Agent: curl/7.35.0
> Host: ***
> Accept: application/json
> Content-type: application/json
> Content-Length: 83
>
* upload completely sent off: 83 out of 83 bytes
< HTTP/1.1 401 UNAUTHORIZED
< Date: Wed, 21 Oct 2015 12:29:17 GMT
* Server Apache/2.4.7 (Ubuntu) is not blacklisted
< Server: Apache/2.4.7 (Ubuntu)
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Authentication Required"
< Content-Length: 19
< Content-Type: text/html; charset=utf-8
<
* Connection #0 to host ***m left intact
Unauthorized Access
有一个由 -u 选项创建的授权 header 。但是在我的 flask 应用程序中没有给出用户名或密码。
@app.auth.verify_password
def verify_password(username, passwd):
print "USername [%s] [%s]" % (username, passwd)
return False
给出的输出是:
USername [] []
所以我的问题是如何使用 curl 为 verify_password 装饰器提供用户名和密码?
谢谢。
最佳答案
您需要配置 mod_wsgi 以将授权 header 传递给您的 Flask 应用程序。
Be aware that some web servers do not pass the Authorization headers to the WSGI application by default.
另外,来自 verify_password
的文档:
If this callback is defined, it is also invoked when the request does not have the Authorization header with user credentials, and in this case both the username and password arguments are set to empty strings.
...这可以解释您看到的输出。
由于您使用的是带有 mod_wsgi 的 Apache,因此您应该设置 WSGIPassAuthorization directive在 Apache 配置中设置为 On
(默认为 Off
)。
关于python - Flask 不使用 curl auth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33259710/
主要问题是可以从已保存的 Auth 对象设置零 Auth 对象: let oldAuth = Auth.auth().currentUser let oldAuthId = Auth.auth().c
何时使用 this.afAuth.auth.signInWithCredential 在我的 Ionic 应用程序中一切正常。我可以使用 Google 身份验证登录并将用户个人资料推送到 fireba
我想在启动时使用我的测试用户帐户预加载 firebase auth 模拟器,就像我对 Firestore 模拟器及其导入/导出选项所做的一样。我尝试在模拟器运行时使用 auth:import 和 au
我正在尝试通过创建 Firebase DataService 来 DRY 我的应用程序,但我不知道为 Auth.auth() 转换什么类型。我查看了源代码定义,但它在我不理解的 Objective C
我有一个更新用户个人资料图片的组件:。我有第二个组件检测用户状态的变化:。问题是,在执行updateProfile()之后,没有触发auth.onAuthStateChanged()。因此,我得到了老
我正在使用 Facebook Javascript SDK,并且正在调整我网站的用户登录系统。我想知道 auth.login/auth.logout 和 auth.sessionChange 之间有什
目前,我正在完成Daniel Kehoe的Learn Ruby on Rails教程。练习之一是使用Google的Gmail帐户从“联系人”页面发送联系人表格。 但是,当我发送联系表格时,没有在邮箱中
我在我的应用中使用 Firebase Auth。我更新电子邮件如下: firebaseAuth.currentUser?.updateEmail(email) 电子邮件正在 100% 更新(必要时我也
在我的应用程序中,当我第一次让用户加入时,我会让他们登录并确认这有效,并且他们会获得一个用户 ID。但稍后在我的 Storyboard 中,我调用了 Auth.auth.currentUser.uid
我是编程新手,我正在尝试从 firebase 数据库中读取数据。我从 Firebase 手册中得到这段代码,我想知道术语 uid,AUTH.auth() 在这里是什么意思。它是一个变量吗?我从 fir
已结束。此问题不符合 Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等方面的建议的问题。您可以编辑问题,以便用事实和引用来回答它。 关闭
背景 我构建了一个连接到 Authorize.net 支付网关的电子商务应用程序。管理员可以通过以下方式处理信用卡: 管理员立即从客户的信用卡中扣款的“捕获”交易。 “仅授权”交易,管理员从信用卡中授
我正在使用 dj-rest-auth ( https://dj-rest-auth.readthedocs.io/en/latest/ ) 并尝试实现自定义注册表单。当我尝试注册新用户时,我有基本表单
我们正在使用 Azure Web App Easy Auth,并使用 Web App 作为反向代理,将流量转发到 Angular 应用程序。 角度应用程序使用/.auth/me 并使用 token 并
我有一个 Controller 和一个如下所示的 View ,它在一段时间内工作完美,但是在向服务器发出一些请求后(即每秒重新加载一次),它将在此行失败 if (!$this->tank_auth-
我希望在单个 Web 应用程序中,部分部分使用身份验证,部分部分完全开放(或者更具体地说,不使用基于容器的身份验证)。 使用基于容器的身份验证的应用程序部分位于 URL /而打开的部分位于 URL /
只要我按下按钮调用 signOut 方法,当前 View Controller 就会被关闭。但是,注销过程是成功的。 (我正在使用 FirebaseAuth SDK。) 这是我的代码: @IBActi
对于Firebase iOS,如果我想做用户认证,这3个选择有什么区别吗? FirebaseUI FirebaseUI/授权 Firebase/授权 如果有人可以解释使用“预构建”FirebaseUI
我正在使用 Vue-auth 包来验证我的 vue-cli 应用程序。一切正常,但当我在我的 vue 操作中访问此代码时,它返回 undefined。有什么想法吗? const AuthService
所以我正在使用 Laravel 身份验证,第一次它工作正常,但删除 Auth 文件夹后,我再次运行 php artisan make:auth 但它不会创建另一个 Auth 文件夹。 View 和模型
我是一名优秀的程序员,十分优秀!