Add basic file upload support
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
type BackupPayload struct {
|
||||
jwt.Payload
|
||||
|
||||
ServerUuid string `json:"server_uuid"`
|
||||
BackupUuid string `json:"backup_uuid"`
|
||||
UniqueId string `json:"unique_id"`
|
||||
@@ -22,4 +23,4 @@ func (p *BackupPayload) GetPayload() *jwt.Payload {
|
||||
// validates all of the request.
|
||||
func (p *BackupPayload) IsUniqueRequest() bool {
|
||||
return getTokenStore().IsValidToken(p.UniqueId)
|
||||
}
|
||||
}
|
||||
|
||||
25
router/tokens/upload.go
Normal file
25
router/tokens/upload.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package tokens
|
||||
|
||||
import (
|
||||
"github.com/gbrlsnchs/jwt/v3"
|
||||
)
|
||||
|
||||
type UploadPayload struct {
|
||||
jwt.Payload
|
||||
|
||||
ServerUuid string `json:"server_uuid"`
|
||||
UniqueId string `json:"unique_id"`
|
||||
}
|
||||
|
||||
// Returns the JWT payload.
|
||||
func (p *UploadPayload) 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 *UploadPayload) IsUniqueRequest() bool {
|
||||
return getTokenStore().IsValidToken(p.UniqueId)
|
||||
}
|
||||
Reference in New Issue
Block a user