Skip to content

Commit

Permalink
Fix: update openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Jan 17, 2024
1 parent d294554 commit 0a4fba5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/evanphx/json-patch v0.5.2
github.com/free5gc/openapi v1.0.7-0.20231216094313-e15a4ff046f6
github.com/free5gc/openapi v1.0.7-0.20240117084712-52ad99299693
github.com/free5gc/util v1.0.5-0.20231001095115-433858e5be94
github.com/gin-gonic/gin v1.9.1
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/free5gc/openapi v1.0.7-0.20231216094313-e15a4ff046f6 h1:8P/wOkTAQMgZJe9pUUNSTE5PWeAdlMrsU9kLsI+VAVE=
github.com/free5gc/openapi v1.0.7-0.20231216094313-e15a4ff046f6/go.mod h1:qv9KqEucoZSeENPRFGxfTe+33ZWYyiYFx1Rj+H0DoWA=
github.com/free5gc/openapi v1.0.7-0.20240117084712-52ad99299693 h1:gFyYBsErQAkx4OVHXYqjO0efO9gPWydQavQcjU0CkHY=
github.com/free5gc/openapi v1.0.7-0.20240117084712-52ad99299693/go.mod h1:qv9KqEucoZSeENPRFGxfTe+33ZWYyiYFx1Rj+H0DoWA=
github.com/free5gc/util v1.0.5-0.20231001095115-433858e5be94 h1:tNylIqH/m5Kq+3KuC+jjXGl06Y6EmM8yq61ZUgNrPBY=
github.com/free5gc/util v1.0.5-0.20231001095115-433858e5be94/go.mod h1:aMszJZbCkcg5xaGgzya+55jz+OPMsJqPLq5Z3fWDFPE=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
Expand Down
6 changes: 3 additions & 3 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ func GetSelf() *NSSFContext {
return &nssfContext
}

func (c *NSSFContext) GetTokenCtx(scope, targetNF string) (
func (c *NSSFContext) GetTokenCtx(scope string, targetNF models.NfType) (
context.Context, *models.ProblemDetails, error,
) {
if !c.OAuth2Required {
return context.TODO(), nil, nil
}
return oauth.GetTokenCtx(models.NfType_NSSF,
c.NfId, c.NrfUri, scope, targetNF)
return oauth.GetTokenCtx(models.NfType_NSSF, targetNF,
c.NfId, c.NrfUri, scope)
}

func (c *NSSFContext) AuthorizationCheck(token, serviceName string) error {
Expand Down
10 changes: 2 additions & 8 deletions internal/sbi/consumer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@ func SendRegisterNFInstance(nrfUri, nfInstanceId string, profile models.NfProfil
configuration.SetBasePath(nrfUri)
apiClient := Nnrf_NFManagement.NewAPIClient(configuration)

ctx := context.Background()
// ctx, _, err := nssf_context.GetSelf().GetTokenCtx("nnrf-nfm", "NRF")
// if err != nil {
// return "", "", errors.Errorf("SendRegisterNFInstance error: %+v", err)
// }

var res *http.Response
var nf models.NfProfile
for {
nf, res, err = apiClient.NFInstanceIDDocumentApi.RegisterNFInstance(ctx, nfInstanceId, profile)
nf, res, err = apiClient.NFInstanceIDDocumentApi.RegisterNFInstance(context.TODO(), nfInstanceId, profile)
if err != nil || res == nil {
// TODO : add log
logger.ConsumerLog.Errorf("NSSF register to NRF Error[%s]", err.Error())
Expand Down Expand Up @@ -99,7 +93,7 @@ func SendDeregisterNFInstance() (*models.ProblemDetails, error) {

var err error

ctx, pd, err := nssf_context.GetSelf().GetTokenCtx("nnrf-nfm", "NRF")
ctx, pd, err := nssf_context.GetSelf().GetTokenCtx("nnrf-nfm", models.NfType_NRF)
if err != nil {
return pd, err
}
Expand Down
3 changes: 2 additions & 1 deletion internal/sbi/nssaiavailability/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"github.com/free5gc/nssf/internal/logger"
"github.com/free5gc/nssf/internal/util"
"github.com/free5gc/nssf/pkg/factory"
"github.com/free5gc/openapi/models"
logger_util "github.com/free5gc/util/logger"
)

const serviceName string = "nnssf-nssaiavailability"
const serviceName string = string(models.ServiceName_NNSSF_NSSAIAVAILABILITY)

// Route is the information for every URI.
type Route struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/sbi/nsselection/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"github.com/free5gc/nssf/internal/logger"
"github.com/free5gc/nssf/internal/util"
"github.com/free5gc/nssf/pkg/factory"
"github.com/free5gc/openapi/models"
logger_util "github.com/free5gc/util/logger"
)

const serviceName string = "nnssf-nsselection"
const serviceName string = string(models.ServiceName_NNSSF_NSSELECTION)

// Route is the information for every URI.
type Route struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/util/router_auth_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (rac *RouterAuthorizationCheck) Check(c *gin.Context, nssfContext nssf_cont
token := c.Request.Header.Get("Authorization")
err := nssfContext.AuthorizationCheck(token, rac.serviceName)
if err != nil {
logger.UtilLog.Debugf("RouterAuthorizationCheck: Check Unauthorized: %s", err)
logger.UtilLog.Debugf("RouterAuthorizationCheck: Check Unauthorized: %s", err.Error())
c.JSON(http.StatusUnauthorized, gin.H{"error": err.Error()})
c.Abort()
return
Expand Down

0 comments on commit 0a4fba5

Please sign in to comment.