basic

package
v6.0.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package basic 实现 Basic 校验

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthFunc

type AuthFunc[T any] func(username, password []byte) (v T, ok bool)

AuthFunc 验证登录用户的函数签名

username,password 表示用户登录信息。 返回值中,ok 表示是否成功验证。如果成功验证, 则 v 为用户希望传递给用户的一些额外信息,比如登录用户的权限组什么的。

type Basic

type Basic[T any] struct {
	// contains filtered or unexported fields
}

Basic 验证中间件

func New

func New[T any](srv *web.Server, auth AuthFunc[T], realm string, proxy bool) *Basic[T]

New 声明一个 Basic 验证的中间件

proxy 是否为代理,主要是报头的输出内容不同,判断方式完全相同。 true 会输出 Proxy-Authorization 和 Proxy-Authenticate 报头和 407 状态码, 而 false 则是输出 Authorization 和 WWW-Authenticate 报头和 401 状态码;

func (*Basic[T]) GetValue

func (b *Basic[T]) GetValue(ctx *web.Context) (T, bool)

func (*Basic[T]) Middleware

func (b *Basic[T]) Middleware(next web.HandlerFunc) web.HandlerFunc

Jump to

Keyboard shortcuts

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