Skip to content

Commit

Permalink
feat: modify ueau route with different layer
Browse files Browse the repository at this point in the history
  • Loading branch information
a3828162 committed Oct 17, 2024
1 parent 1e2b8fe commit f82f577
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 60 deletions.
108 changes: 57 additions & 51 deletions internal/sbi/api_ueauthentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,6 @@ func (s *Server) getUEAuthenticationRoutes() []Route {
"/",
s.HandleIndex,
},

{
"ConfirmAuth",
http.MethodPost,
"/:supi/auth-events",
s.HandleConfirmAuth,
},

{
"DeleteAuth",
http.MethodPut,
"/:supi/auth-events/:authEventId",
s.HandleDeleteAuth,
},

{
"GenerateAv",
http.MethodPost,
"/:supi/hss-security-information/:hssAuthType/generate-av",
s.HandleGenerateAv,
},

{
"GenerateGbaAv",
http.MethodPost,
"/:supi/gba-security-information/generate-av",
s.HandleGenerateGbaAv,
},

{
"GenerateProseAV",
http.MethodPost,
"/:supiOrSuci/prose-security-information/generate-av",
s.HandleGenerateProseAV,
},

{
"GetRgAuthData",
http.MethodGet,
"/:supiOrSuci/security-information-rg",
s.HandleGetRgAuthData,
},
}
}

Expand Down Expand Up @@ -136,15 +94,6 @@ func (s *Server) HandleGenerateAuthData(c *gin.Context) {
s.Processor().GenerateAuthDataProcedure(c, authInfoReq, supiOrSuci)
}

func (s *Server) GenAuthDataHandlerFunc(c *gin.Context) {
if http.MethodPost == c.Request.Method {
s.HandleGenerateAuthData(c)
return
}

c.String(http.StatusNotFound, "404 page not found")
}

func (s *Server) HandleDeleteAuth(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
Expand All @@ -164,3 +113,60 @@ func (s *Server) HandleGenerateProseAV(c *gin.Context) {
func (s *Server) HandleGetRgAuthData(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) UEAUTwoLayerPathHandlerFunc(c *gin.Context) {
twoLayer := c.Param("twoLayer")

// for "/:supi/auth-events"
if twoLayer == "auth-events" && http.MethodPost == c.Request.Method {
s.HandleConfirmAuth(c)
return
}

// for "/:supiOrSuci/security-information-rg"
if twoLayer == "security-information-rg" && http.MethodGet == c.Request.Method {
var tmpParams gin.Params
tmpParams = append(tmpParams, gin.Param{Key: "supiOrSuci", Value: c.Param("supi")})
c.Params = tmpParams
s.HandleGetRgAuthData(c)
return
}

c.String(http.StatusNotFound, "404 page not found")
}

func (s *Server) UEAUThreeLayerPathHandlerFunc(c *gin.Context) {
twoLayer := c.Param("subscriptionId")

// for "/:supi/auth-events/:authEventId"
if twoLayer == "auth-events" && http.MethodPut == c.Request.Method {
s.HandleDeleteAuth(c)
return
}

// for "/:supi/gba-security-information/generate-av"
if twoLayer == "gba-security-information" && http.MethodPost == c.Request.Method {
s.HandleGenerateGbaAv(c)
return
}

// for "/:supiOrSuci/prose-security-information/generate-av"
if twoLayer == "prose-security-information" && http.MethodPost == c.Request.Method {
var tmpParams gin.Params
tmpParams = append(tmpParams, gin.Param{Key: "supiOrSuci", Value: c.Param("supi")})
c.Params = tmpParams
s.HandleGenerateProseAV(c)
return
}

// for "/:supiOrSuci/security-information/generate-auth-data"
if twoLayer == "security-information" && http.MethodPost == c.Request.Method {
var tmpParams gin.Params
tmpParams = append(tmpParams, gin.Param{Key: "supiOrSuci", Value: c.Param("supi")})
c.Params = tmpParams
s.HandleGenerateAuthData(c)
return
}

c.String(http.StatusNotFound, "404 page not found")
}
10 changes: 3 additions & 7 deletions internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/pkg/errors"

"github.com/free5gc/openapi"
"github.com/free5gc/openapi/models"
Nnrf_NFDiscovery "github.com/free5gc/openapi/nrf/NFDiscovery"
Nnrf_NFManagement "github.com/free5gc/openapi/nrf/NFManagement"
Expand Down Expand Up @@ -150,12 +149,9 @@ func (s *nnrfService) RegisterNFInstance(ctx context.Context) (
res, err = client.NFInstanceIDDocumentApi.RegisterNFInstance(ctx, &registerNfInstanceRequest)

if err != nil || res == nil {
problem, ok := err.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
if !ok {
logger.ConsumerLog.Errorf("UDM register to NRF Error[%v]", problem)
time.Sleep(2 * time.Second)
continue
}
logger.ConsumerLog.Errorf("UDM register to NRF Error[%v]", err.Error())
time.Sleep(2 * time.Second)
continue
}

if res.Location == "" {
Expand Down
10 changes: 8 additions & 2 deletions internal/sbi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ func newRouter(s *Server) *gin.Engine {
})
AddService(udmUEAUGroup, udmUEAURoutes)

genAuthDataPath := "/:supiOrSuci/security-information/generate-auth-data"
udmUEAUGroup.Any(genAuthDataPath, s.GenAuthDataHandlerFunc)
ueauTwoLayerPath := "/:supi/:twoLayer"
udmUEAUGroup.Any(ueauTwoLayerPath, s.UEAUTwoLayerPathHandlerFunc)

ueauThreeLayerPath := "/:supi/:twoLayer/:thirdLayer"
udmUEAUGroup.Any(ueauThreeLayerPath, s.UEAUThreeLayerPathHandlerFunc)

generateAvPath := "/:supi/hss-security-information/:hssAuthType/generate-av"
udmUEAUGroup.Any(generateAvPath, s.HandleGenerateAv)

// UECM
udmUECMRoutes := s.getUEContextManagementRoutes()
Expand Down

0 comments on commit f82f577

Please sign in to comment.