digest

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package digest 实现 digest 验证

NOTE: 这是个未完成的功能,请勿使用

https://tools.ietf.org/html/rfc7616

TODO: Authorization-Info 等输出的处理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(next http.Handler, auth AuthFunc, realm string, proxy bool, errlog *log.Logger) http.Handler

New 声明一个摘要验证的中间件

next 表示验证通过之后,需要执行的 handler; proxy 是否为代码,主要是报头的输出内容不同,判断方式完全相同。 true 会输出 Proxy-Authorization 和 Proxy-Authenticate 报头和 407 状态码, 而 false 则是输出 Authorization 和 WWW-Authenticate 报头和 401 状态码; log 如果不为 nil,则在运行过程中的错误,将输出到此日志。

Types

type AuthFunc

type AuthFunc func(username string) (v interface{}, password string, found bool)

AuthFunc 查找到指定名称的用户数据

username 表示用户名称; v 表示在验证成功的情况下,希望附加到 Request.Context 中的数据; password 表示该用户对应的密码; found 表示是否找到数据;

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL