douhuan3420 2012-01-19 22:52
浏览 23
已采纳

Go,基本访问身份验证

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥21 matlab可以把图像数据转换为小波分析吗
  • ¥60 基于香农编码的图像压缩算法实现
  • ¥15 实现胶囊神经网络,最好可以远程操作
  • ¥15 matlabGUI绘制一个函数与其导数的图像
  • ¥20 大数据采集用Python爬取猫眼电影数据
  • ¥15 用freertos后NVIC里系统时钟部分报错
  • ¥15 后缀表达式的计算算法问题
  • ¥15 安装mid360驱动后,执行rviz_MID360.launch rviz不显示
  • ¥15 关于#人工智能#的问题:(2)设计一个GUI,允许语音和文本实现谣言的检测
  • ¥50 请教 麒麟系统挂载怎么安装