From da274d1b746783d03228c7d9f9c27bd05ea5271b Mon Sep 17 00:00:00 2001
From: "CTFang@WireLab" <ctfang.cs12@nycu.edu.tw>
Date: Thu, 7 Mar 2024 06:44:42 +0000
Subject: [PATCH] Remove nrfCertPem and add AfType in NfProfile

---
 backend/factory/config.go               | 1 -
 backend/webui_context/context.go        | 2 --
 backend/webui_context/nrf_management.go | 6 +++---
 config/webuicfg.yaml                    | 1 -
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/backend/factory/config.go b/backend/factory/config.go
index fc98705..6bdd2f2 100644
--- a/backend/factory/config.go
+++ b/backend/factory/config.go
@@ -43,7 +43,6 @@ type Configuration struct {
 	WebServer     *WebServer     `yaml:"webServer,omitempty" valid:"optional"`
 	Mongodb       *Mongodb       `yaml:"mongodb" valid:"required"`
 	NrfUri        string         `yaml:"nrfUri" valid:"required"`
-	NrfCertPem    string         `yaml:"nrfCertPem,omitempty" valid:"optional"`
 	BillingServer *BillingServer `yaml:"billingServer,omitempty" valid:"required"`
 }
 
diff --git a/backend/webui_context/context.go b/backend/webui_context/context.go
index 35f69bd..3414c33 100644
--- a/backend/webui_context/context.go
+++ b/backend/webui_context/context.go
@@ -24,7 +24,6 @@ type WEBUIContext struct {
 	BillingServer  *billing.BillingDomain
 
 	NrfUri         string
-	NrfCertPem     string
 	OAuth2Required bool
 
 	NFManagementClient *Nnrf_NFManagement.APIClient
@@ -40,7 +39,6 @@ type NfOamInstance struct {
 func Init() {
 	webuiContext.NfInstanceID = uuid.New().String()
 	webuiContext.NrfUri = factory.WebuiConfig.Configuration.NrfUri
-	webuiContext.NrfCertPem = factory.WebuiConfig.Configuration.NrfCertPem
 
 	ManagementConfig := Nnrf_NFManagement.NewConfiguration()
 	ManagementConfig.SetBasePath(GetSelf().NrfUri)
diff --git a/backend/webui_context/nrf_management.go b/backend/webui_context/nrf_management.go
index 20f2a3b..f463a47 100644
--- a/backend/webui_context/nrf_management.go
+++ b/backend/webui_context/nrf_management.go
@@ -17,6 +17,9 @@ func SendNFRegistration() error {
 		NfInstanceId: GetSelf().NfInstanceID,
 		NfType:       models.NfType_AF,
 		NfStatus:     models.NfStatus_REGISTERED,
+		CustomInfo: map[string]interface{}{
+			"AfType": "webconsole",
+		},
 	}
 
 	var nf models.NfProfile
@@ -57,9 +60,6 @@ func SendNFRegistration() error {
 				}
 			}
 			GetSelf().OAuth2Required = oauth2
-			if oauth2 && GetSelf().NrfCertPem == "" {
-				logger.CfgLog.Error("OAuth2 enable but no nrfCertPem provided in config.")
-			}
 			break
 		} else {
 			logger.ConsumerLog.Infof("handler returned wrong status code %d", status)
diff --git a/config/webuicfg.yaml b/config/webuicfg.yaml
index e35022f..4496ea0 100644
--- a/config/webuicfg.yaml
+++ b/config/webuicfg.yaml
@@ -7,7 +7,6 @@ configuration:
     name: free5gc # name of the mongodb
     url: mongodb://localhost:27017 # a valid URL of the mongodb
   nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
-  nrfCertPem: cert/nrf.pem
   webServer:
     scheme: http
     ipv4Address: 0.0.0.0
-- 
GitLab