package
Version:
v6.1.0
Opens a new window with list of versions in this module.
Published: Mar 5, 2024
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package basic 实现 Basic 校验
New 声明一个 Basic 验证的中间件
proxy 是否为代理,主要是报头的输出内容不同,判断方式完全相同。
true 会输出 Proxy-Authorization 和 Proxy-Authenticate 报头和 407 状态码,
而 false 则是输出 Authorization 和 WWW-Authenticate 报头和 401 状态码;
T 表示验证成功之后,向用户传递的一些额外信息。之后可通过 [Basic.GetValue] 获取。
type AuthFunc[T any] func(username, password []byte) (v T, ok bool)
AuthFunc 验证登录用户的函数签名
username,password 表示用户登录信息。
返回值中,ok 表示是否成功验证。如果成功验证,
则 v 为希望传递给用户的一些额外信息,比如登录用户的权限组什么的。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.