Revert "v1: pagination now deterministic"
This reverts commit 24f329fea674e04c76f5e87c22eea1800e6bc413. This was unnecessary.
This commit is contained in:
parent
3563cf9061
commit
1557a27a8c
@ -15,6 +15,8 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
@ -295,15 +297,19 @@ func tokenToPageNumber(token, key string) (database.VulnerabilityNotificationPag
|
||||
}
|
||||
|
||||
page := database.VulnerabilityNotificationPageNumber{}
|
||||
_, err := fmt.Sscanf(string(msg), "old:%d|new:%d", &page.OldVulnerability, &page.NewVulnerability)
|
||||
err := json.NewDecoder(bytes.NewBuffer(msg)).Decode(&page)
|
||||
return page, err
|
||||
}
|
||||
|
||||
func pageNumberToToken(page database.VulnerabilityNotificationPageNumber, key string) string {
|
||||
unencryptedToken := []byte(fmt.Sprintf("old:%d|new:%d", page.OldVulnerability, page.NewVulnerability))
|
||||
var buf bytes.Buffer
|
||||
err := json.NewEncoder(&buf).Encode(page)
|
||||
if err != nil {
|
||||
log.Fatal("failed to encode VulnerabilityNotificationPageNumber")
|
||||
}
|
||||
|
||||
k, _ := fernet.DecodeKey(key)
|
||||
tokenBytes, err := fernet.EncryptAndSign(unencryptedToken, k)
|
||||
tokenBytes, err := fernet.EncryptAndSign(buf.Bytes(), k)
|
||||
if err != nil {
|
||||
log.Fatal("failed to encrypt VulnerabilityNotificationpageNumber")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user