Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func NewHeaderBearerTokenGetter(header string) *BearerGetter {
//
// store is the TokenStore that stores and verify the tokens
func New(tokenStore *JwtStore, store storage.Database) *TokenAuth {
if !store.Active() {
panic("auth: store is not active - did you forget to call store.Start()?")
}
t := &TokenAuth{
tokenStore: tokenStore,
store: store,
Expand Down Expand Up @@ -672,6 +675,9 @@ func (t *TokenAuth) NewPassword(w http.ResponseWriter, r *http.Request) {

// Routes handle for auth enpoints
func (t *TokenAuth) Routes(server *ooo.Server) {
if !t.store.Active() {
panic("auth: store is not active - did you forget to call store.Start()?")
}
server.Router.HandleFunc("/authorize", t.Authorize()).Methods(http.MethodPost, http.MethodPut)
server.Router.HandleFunc("/profile", t.Profile()).Methods(http.MethodGet)
server.Router.HandleFunc("/users", t.Users()).Methods(http.MethodGet)
Expand Down
1 change: 1 addition & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestRegisterAndAuthorize(t *testing.T) {
authStore := storage.New(storage.LayeredConfig{
Memory: storage.NewMemoryLayer(),
})
authStore.Start(storage.Options{})
go storage.WatchStorageNoop(authStore)
auth := New(
NewJwtStore("a-secret-key-0-asdasdada-asdasdasd-asdasdsaweenvurh@!@#12", time.Second*1),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/benitogf/auth
go 1.25

require (
github.com/benitogf/ooo v0.0.0-20260109055348-efad8e781ed7
github.com/benitogf/ooo v0.0.0-20260202060447-566ed1c50fb9
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/gorilla/mux v1.8.1
github.com/stretchr/testify v1.11.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/benitogf/jsonpatch v0.0.0-20260109052650-eec54232a9a2 h1:OC5ZiOG0sQ5Q
github.com/benitogf/jsonpatch v0.0.0-20260109052650-eec54232a9a2/go.mod h1:O1Z+hTPUrXzHUjmKlpmNYK9wcncZ5rS3K8PqItDO0x0=
github.com/benitogf/ooo v0.0.0-20260109055348-efad8e781ed7 h1:qNmJ0qTWXW8k8XYLMfXy4cEYEA2VwMTL6P+GUFbdhHo=
github.com/benitogf/ooo v0.0.0-20260109055348-efad8e781ed7/go.mod h1:fqf1bDkBBOOiCExWW1qdj59ldb/yqfJc3gTfskl02cU=
github.com/benitogf/ooo v0.0.0-20260202060447-566ed1c50fb9 h1:P4TAfI7Hr8NzOuHqnwkO21lef3yaMG0TEo0M+F0ue4Y=
github.com/benitogf/ooo v0.0.0-20260202060447-566ed1c50fb9/go.mod h1:fqf1bDkBBOOiCExWW1qdj59ldb/yqfJc3gTfskl02cU=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down