mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-11 19:18:46 +00:00
Previously Anubis constructed challenge strings from request metadata. This was a good idea in spirit, but has turned out to be a very bad idea in practice. This new flow reuses the Store facility to dynamically create challenge values with completely random data. This is a fairly big rewrite of how Anubis processes challenges. Right now it defaults to using the in-memory storage backend, but on-disk (boltdb) and valkey-based adaptors will come soon. Signed-off-by: Xe Iaso <me@xeiaso.net>
24 lines
426 B
Go
24 lines
426 B
Go
package challengetest
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/TecharoHQ/anubis/internal"
|
|
"github.com/TecharoHQ/anubis/lib/challenge"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func New(t *testing.T) *challenge.Challenge {
|
|
t.Helper()
|
|
|
|
id := uuid.Must(uuid.NewV7())
|
|
randomData := internal.SHA256sum(time.Now().String())
|
|
|
|
return &challenge.Challenge{
|
|
ID: id.String(),
|
|
RandomData: randomData,
|
|
IssuedAt: time.Now(),
|
|
}
|
|
}
|