Authenticate 验证 API Key
(ctx context.Context, credentials any)
| 55 | |
| 56 | // Authenticate 验证 API Key |
| 57 | func (a *APIKeyAuthenticator) Authenticate(ctx context.Context, credentials any) (*User, error) { |
| 58 | key, ok := credentials.(string) |
| 59 | if !ok { |
| 60 | return nil, ErrInvalidCredentials |
| 61 | } |
| 62 | |
| 63 | return a.Validate(ctx, key) |
| 64 | } |
| 65 | |
| 66 | // Validate 验证 API Key 并返回用户信息 |
| 67 | func (a *APIKeyAuthenticator) Validate(ctx context.Context, key string) (*User, error) { |