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.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥21 matlab可以把图像数据转换为小波分析吗
- ¥60 基于香农编码的图像压缩算法实现
- ¥15 实现胶囊神经网络,最好可以远程操作
- ¥15 matlabGUI绘制一个函数与其导数的图像
- ¥20 大数据采集用Python爬取猫眼电影数据
- ¥15 用freertos后NVIC里系统时钟部分报错
- ¥15 后缀表达式的计算算法问题
- ¥15 安装mid360驱动后,执行rviz_MID360.launch rviz不显示
- ¥15 关于#人工智能#的问题:(2)设计一个GUI,允许语音和文本实现谣言的检测
- ¥50 请教 麒麟系统挂载怎么安装