From f7f076fa57bd63838ed5430e752d2bc8627895e7 Mon Sep 17 00:00:00 2001 From: chh Date: Mon, 22 Jan 2024 03:44:02 +0000 Subject: [PATCH] finished communication/routers.go --- internal/sbi/communication/routers.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/sbi/communication/routers.go b/internal/sbi/communication/routers.go index d809284..4040e3b 100644 --- a/internal/sbi/communication/routers.go +++ b/internal/sbi/communication/routers.go @@ -15,13 +15,15 @@ import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" - + "github.com/free5gc/amf/internal/util" + "github.com/free5gc/openapi/models" "github.com/free5gc/amf/internal/logger" "github.com/free5gc/amf/pkg/factory" logger_util "github.com/free5gc/util/logger" - + amf_context "github.com/free5gc/amf/internal/context" ) +const serviceName string = string(models.ServiceName_NAMF_COMM) var HttpLog *logrus.Entry func init() { @@ -53,6 +55,11 @@ func NewRouter() *gin.Engine { func AddService(engine *gin.Engine) *gin.RouterGroup { group := engine.Group(factory.AmfCommResUriPrefix) + routerAuthorizationCheck := util.NewRouterAuthorizationCheck(serviceName) + group.Use(func(c *gin.Context) { + routerAuthorizationCheck.Check(c, amf_context.GetSelf()) + }) + for _, route := range routes { switch route.Method { case "GET":