重构认证相关结构,更新认证流程,添加日志功能

This commit is contained in:
2025-02-26 17:01:20 +08:00
parent 7ee4ded08c
commit a541a7bd3a
12 changed files with 110 additions and 472 deletions

View File

@@ -23,11 +23,11 @@ const (
type Authenticator interface {
Method() AuthMethod
Authenticate(ctx context.Context, reader io.Reader, writer io.Writer) (*AuthContext, error)
Authenticate(ctx context.Context, reader io.Reader, writer io.Writer) (*Authentication, error)
}
// authenticate 执行认证流程
func (s *Server) authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error) {
func (s *Server) authenticate(reader io.Reader, writer io.Writer) (*Authentication, error) {
// 版本检查
err := checkVersion(reader)
@@ -75,8 +75,13 @@ func (s *Server) authenticate(reader io.Reader, writer io.Writer) (*AuthContext,
return nil, errors.New("没有适用的认证方式")
}
type AuthContext struct {
type Authentication struct {
Method AuthMethod
Timeout uint
Payload map[string]any
Payload Payload
Data map[string]any
}
type Payload struct {
ID uint
}