Does Google Go support decoding of basic access authentication calls? How do I get the username and password from the http.Request?
2条回答 默认 最新
- drx3157 2012-01-21 01:10关注
Go does not seem to intercept basic authentication when it is typed as an URL in a browser, but it does allow one to get it from some other applications calling it.
For example, using a simple Python code for HTTP JSON RPC:
from jsonrpc import ServiceProxy access = ServiceProxy("http://user:pass@127.0.0.1:8080/") print access.getinfo()
And in Go calling:
// r *http.Request r.Header["Authorization"]
One gets this string:
[Basic dXNlcjpwYXNz]
And
dXNlcjpwYXNz
Base-64 decoded gives
user:pass
So some basic authentication in Go is possible, although it might not be something one can rely on.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 vscode下编写第三方库opencv与pcl代码时没有代码提示
- ¥15 能够跑通不报错,如何解决?(标签-matlab)
- ¥15 MOS在RDS较大,频率高时开关波形异常
- ¥15 SCENIC分析报错求解答
- ¥15 ceph初始化mon不成功 下图不报错 这个是什么元
- ¥15 数学建模数学建模少ai
- ¥15 如何把LibreOffice添加到自定义层中
- ¥35 这个等效电路图是什么意思?(答疑)(有没有不是chat的,我就是在chat搜不到才来问的,chat还开了VIP)(可以追加酬金)
- ¥200 基于同花顺supermind的量化策略脚本编辑
- ¥20 Html备忘录页面制作