wings/router/tokens/backup.go

27 lines
673 B
Go
Raw Permalink Normal View History

2020-04-06 01:56:54 +00:00
package tokens
import (
"github.com/gbrlsnchs/jwt/v3"
)
type BackupPayload struct {
jwt.Payload
2020-07-12 22:43:25 +00:00
2020-04-06 01:56:54 +00:00
ServerUuid string `json:"server_uuid"`
BackupUuid string `json:"backup_uuid"`
UniqueId string `json:"unique_id"`
}
// Returns the JWT payload.
func (p *BackupPayload) GetPayload() *jwt.Payload {
return &p.Payload
}
// Determines if this JWT is valid for the given request cycle. If the
// unique ID passed in the token has already been seen before this will
// return false. This allows us to use this JWT as a one-time token that
// validates all of the request.
func (p *BackupPayload) IsUniqueRequest() bool {
return getTokenStore().IsValidToken(p.UniqueId)
2020-07-12 22:43:25 +00:00
}