shaj13 / go-guardian

Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.
MIT License
559 stars 56 forks source link

Issue with go-guardian jwt example #127

Closed mkvy closed 1 year ago

mkvy commented 1 year ago

https://github.com/shaj13/go-guardian/blob/master/_examples/jwt/main.go example here contains come code with deprecated RegisterOnExpired method:

func setupGoGuardian() {
    keeper = jwt.StaticSecret{
        ID:        "secret-id",
        Secret:    []byte("secret"),
        Algorithm: jwt.HS256,
    }
    cache := libcache.FIFO.New(0)
    cache.SetTTL(time.Minute * 5)
    cache.RegisterOnExpired(func(key, _ interface{}) {
        cache.Peek(key)
    })
    basicStrategy := basic.NewCached(validateUser, cache)
    jwtStrategy := jwt.New(cache, keeper)
    strategy = union.New(jwtStrategy, basicStrategy)
}

Causes panic: RegisterOnExpired no longer available