feat: Added basic user authorization
This commit is contained in:
@@ -3,13 +3,16 @@ package service
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.ostiwe.com/ostiwe-com/status/modules/jwt"
|
||||
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
||||
http2 "git.ostiwe.com/ostiwe-com/status/pkg/http"
|
||||
"git.ostiwe.com/ostiwe-com/status/repository"
|
||||
"git.ostiwe.com/ostiwe-com/status/router/controller"
|
||||
"git.ostiwe.com/ostiwe-com/status/router/midlleware"
|
||||
"git.ostiwe.com/ostiwe-com/status/transform"
|
||||
"github.com/go-andiamo/chioas"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/jwtauth/v5"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@@ -32,7 +35,16 @@ func (c *Controller) public(r chi.Router) {
|
||||
}
|
||||
|
||||
func (c *Controller) internal(r chi.Router) {
|
||||
r.Get("/api/v1/service", c.GetAllServices)
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(
|
||||
jwtauth.Verifier(jwt.TokenAuth),
|
||||
jwtauth.Authenticator(jwt.TokenAuth),
|
||||
midlleware.SetUserFromJWT,
|
||||
)
|
||||
|
||||
r.Get("/api/v1/service", c.GetAllServices)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (c *Controller) GetAllServicesPublic(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user