mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-04 21:29:29 +02:00
- Clients now subscribe to peer status changes. - The server manages and maintains these subscriptions. - Replaced raw string peer IDs with a custom peer ID type for better type safety and clarity.
29 lines
740 B
Go
29 lines
740 B
Go
package auth
|
|
|
|
import (
|
|
"time"
|
|
|
|
auth "github.com/netbirdio/netbird/relay/auth/hmac"
|
|
authv2 "github.com/netbirdio/netbird/relay/auth/hmac/v2"
|
|
)
|
|
|
|
type TimedHMACValidator struct {
|
|
authenticatorV2 *authv2.Validator
|
|
authenticator *auth.TimedHMACValidator
|
|
}
|
|
|
|
func NewTimedHMACValidator(secret []byte, duration time.Duration) *TimedHMACValidator {
|
|
return &TimedHMACValidator{
|
|
authenticatorV2: authv2.NewValidator(secret),
|
|
authenticator: auth.NewTimedHMACValidator(string(secret), duration),
|
|
}
|
|
}
|
|
|
|
func (a *TimedHMACValidator) Validate(credentials any) error {
|
|
return a.authenticatorV2.Validate(credentials)
|
|
}
|
|
|
|
func (a *TimedHMACValidator) ValidateHelloMsgType(credentials any) error {
|
|
return a.authenticator.Validate(credentials)
|
|
}
|