Skip to content

Commit

Permalink
feat(middleware): add auth based on nip-98.
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Jan 19, 2025
1 parent a3f75ba commit ba09952
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions deliveries/http/middlewares/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/nbd-wtf/go-nostr"
)

const oneMinute = 60 * time.Second

func Auth(url string) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
Expand Down Expand Up @@ -65,7 +63,7 @@ func CheckAuthEvent(e *nostr.Event, url string) bool {
}

diff := time.Until(e.CreatedAt.Time())
if !(diff <= oneMinute && diff >= -oneMinute) {
if !(diff <= time.Minute && diff >= -time.Minute) {
return false
}

Expand Down

0 comments on commit ba09952

Please sign in to comment.