Added access checking middleware

Added URLAccessRepository
Refactor
This commit is contained in:
PB
2025-10-22 10:53:20 +02:00
parent 89b665c3d9
commit 662a9b7ffd
11 changed files with 192 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
package server
import (
domain "git.ego.freeddns.org/egommerce/identity-service/domain/repository"
"git.ego.freeddns.org/egommerce/identity-service/internal/service"
"github.com/gofiber/fiber/v2"
)
func (s *Server) AccessHandlerFn(c *fiber.Ctx) error {
url, srvName := c.Query("q"), c.Query("srv")
urlRepo := domain.NewURLAccessRepository(s.GetDatabase())
userRepo := domain.NewUserRepository(s.GetDatabase())
authSrv := service.NewAuthService(userRepo, s.GetCache())
authSrv.VerifyToken("asd")
urlAcc, err := urlRepo.FindByURLAndService(url, srvName)
if err != nil {
return s.Error(c, fiber.StatusBadRequest, "unable to fetch requested url data")
}
return c.JSON(urlAcc.Roles)
}