From 8d10e71e593d717cd6d6a4b877c8564f695252f2 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Thu, 30 Nov 2023 04:30:08 +0000 Subject: [PATCH] Rebase and modify config setting --- go.mod | 3 +-- internal/sbi/datarepository/routers.go | 2 +- pkg/factory/config.go | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index a1fdea5..3eccc5f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/free5gc/udr go 1.17 require ( - github.com/antihax/optional v1.0.0 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.20231112094355-a96c3450377e @@ -15,11 +14,11 @@ require ( github.com/stretchr/testify v1.8.3 github.com/urfave/cli v1.22.5 go.mongodb.org/mongo-driver v1.8.4 - golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 gopkg.in/yaml.v2 v2.4.0 ) require ( + github.com/antihax/optional v1.0.0 // indirect github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect diff --git a/internal/sbi/datarepository/routers.go b/internal/sbi/datarepository/routers.go index f8001d5..df5da86 100644 --- a/internal/sbi/datarepository/routers.go +++ b/internal/sbi/datarepository/routers.go @@ -276,7 +276,7 @@ func HandleAppDataInfluDataSubsToNotifyConflictPut(c *gin.Context) { func authorizationCheck(c *gin.Context) error { if factory.UdrConfig.GetOAuth() { oauth_err := oauth.VerifyOAuth(c.Request.Header.Get("Authorization"), "nudr-dr", - factory.UdrConfig.GetNrfCertPemPath()) + factory.UdrConfig.GetNrfCerPem()) if oauth_err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": oauth_err.Error()}) return oauth_err diff --git a/pkg/factory/config.go b/pkg/factory/config.go index 6d9ffba..7e53954 100644 --- a/pkg/factory/config.go +++ b/pkg/factory/config.go @@ -60,10 +60,11 @@ type ServiceList struct { } type Configuration struct { - Sbi *Sbi `yaml:"sbi" valid:"required"` - Mongodb *Mongodb `yaml:"mongodb" valid:"required"` - NrfUri string `yaml:"nrfUri" valid:"url,required"` - NrfCerPem string `yaml:"nrfCerPem,omitempty" valid:"type(string),minstringlength(1),optional"` + Sbi *Sbi `yaml:"sbi" valid:"required"` + ServiceList []ServiceList `yaml:"serviceList" valid:"optional"` + Mongodb *Mongodb `yaml:"mongodb" valid:"required"` + NrfUri string `yaml:"nrfUri" valid:"url,required"` + NrfCerPem string `yaml:"nrfCerPem,omitempty" valid:"type(string),minstringlength(1),optional"` } type Logger struct { @@ -90,10 +91,10 @@ type Sbi struct { OAuth bool `yaml:"oauth,omitempty" valid:"optional"` } -func (c *Config) GetNrfCertPemPath() string { +func (c *Config) GetNrfCerPem() string { c.RLock() defer c.RUnlock() - return c.Configuration.NrfCertPemPath + return c.Configuration.NrfCerPem } func (c *Config) GetOAuth() bool {