diff --git a/internal/sbi/consumer/nf_accesstoken.go b/internal/sbi/consumer/nf_accesstoken.go index a6311dc..e990e80 100644 --- a/internal/sbi/consumer/nf_accesstoken.go +++ b/internal/sbi/consumer/nf_accesstoken.go @@ -8,7 +8,6 @@ import ( "golang.org/x/oauth2" "github.com/free5gc/openapi" - "github.com/free5gc/openapi/Nnrf_AccessToken" "github.com/free5gc/openapi/models" udr_context "github.com/free5gc/udr/internal/context" diff --git a/internal/sbi/datarepository/api_access_and_mobility_subscription_data_document.go b/internal/sbi/datarepository/api_access_and_mobility_subscription_data_document.go index 243bad7..373c76d 100644 --- a/internal/sbi/datarepository/api_access_and_mobility_subscription_data_document.go +++ b/internal/sbi/datarepository/api_access_and_mobility_subscription_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQueryAmData - Retrieves the access and mobility subscription data of a UE func HTTPQueryAmData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_amf3_gpp_access_registration_document.go b/internal/sbi/datarepository/api_amf3_gpp_access_registration_document.go index 29ce877..c301099 100644 --- a/internal/sbi/datarepository/api_amf3_gpp_access_registration_document.go +++ b/internal/sbi/datarepository/api_amf3_gpp_access_registration_document.go @@ -23,6 +23,11 @@ import ( // HTTPAmfContext3gpp - To modify the AMF context data of a UE using 3gpp access in the UDR func HTTPAmfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPAmfContext3gpp(c *gin.Context) { // HTTPCreateAmfContext3gpp - To store the AMF context data of a UE using 3gpp access in the UDR func HTTPCreateAmfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var amf3GppAccessRegistration models.Amf3GppAccessRegistration requestBody, err := c.GetRawData() @@ -121,6 +131,11 @@ func HTTPCreateAmfContext3gpp(c *gin.Context) { // HTTPQueryAmfContext3gpp - Retrieves the AMF context data of a UE using 3gpp access func HTTPQueryAmfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_amf_non3_gpp_access_registration_document.go b/internal/sbi/datarepository/api_amf_non3_gpp_access_registration_document.go index 38d60c6..e365be2 100644 --- a/internal/sbi/datarepository/api_amf_non3_gpp_access_registration_document.go +++ b/internal/sbi/datarepository/api_amf_non3_gpp_access_registration_document.go @@ -23,6 +23,11 @@ import ( // HTTPAmfContextNon3gpp - To modify the AMF context data of a UE using non 3gpp access in the UDR func HTTPAmfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPAmfContextNon3gpp(c *gin.Context) { // HTTPCreateAmfContextNon3gpp - To store the AMF context data of a UE using non-3gpp access in the UDR func HTTPCreateAmfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var amfNon3GppAccessRegistration models.AmfNon3GppAccessRegistration requestBody, err := c.GetRawData() @@ -121,6 +131,11 @@ func HTTPCreateAmfContextNon3gpp(c *gin.Context) { // HTTPQueryAmfContextNon3gpp - Retrieves the AMF context data of a UE using non-3gpp access func HTTPQueryAmfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_amf_subscription_info_document.go b/internal/sbi/datarepository/api_amf_subscription_info_document.go index 4cf986e..6f57285 100644 --- a/internal/sbi/datarepository/api_amf_subscription_info_document.go +++ b/internal/sbi/datarepository/api_amf_subscription_info_document.go @@ -23,6 +23,11 @@ import ( // HTTPModifyAmfSubscriptionInfo - modify the AMF Subscription Info func HTTPModifyAmfSubscriptionInfo(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_authentication_data_document.go b/internal/sbi/datarepository/api_authentication_data_document.go index 4fca7b1..1786f19 100644 --- a/internal/sbi/datarepository/api_authentication_data_document.go +++ b/internal/sbi/datarepository/api_authentication_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPModifyAuthentication - modify the authentication subscription data of a UE func HTTPModifyAuthentication(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPModifyAuthentication(c *gin.Context) { // HTTPQueryAuthSubsData - Retrieves the authentication subscription data of a UE func HTTPQueryAuthSubsData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_authentication_so_r_document.go b/internal/sbi/datarepository/api_authentication_so_r_document.go index 2467484..422dfba 100644 --- a/internal/sbi/datarepository/api_authentication_so_r_document.go +++ b/internal/sbi/datarepository/api_authentication_so_r_document.go @@ -23,6 +23,11 @@ import ( // HTTPCreateAuthenticationSoR - To store the SoR acknowledgement information of a UE func HTTPCreateAuthenticationSoR(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var sorData models.SorData requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateAuthenticationSoR(c *gin.Context) { // HTTPQueryAuthSoR - Retrieves the SoR acknowledgement information of a UE func HTTPQueryAuthSoR(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_authentication_status_document.go b/internal/sbi/datarepository/api_authentication_status_document.go index 53d708e..bd5300a 100644 --- a/internal/sbi/datarepository/api_authentication_status_document.go +++ b/internal/sbi/datarepository/api_authentication_status_document.go @@ -23,6 +23,11 @@ import ( // HTTPCreateAuthenticationStatus - To store the Authentication Status data of a UE func HTTPCreateAuthenticationStatus(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var authEvent models.AuthEvent requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateAuthenticationStatus(c *gin.Context) { // HTTPQueryAuthenticationStatus - Retrieves the Authentication Status of a UE func HTTPQueryAuthenticationStatus(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_default.go b/internal/sbi/datarepository/api_default.go index a187d67..e795866 100644 --- a/internal/sbi/datarepository/api_default.go +++ b/internal/sbi/datarepository/api_default.go @@ -58,18 +58,33 @@ func getDataFromRequestBody(c *gin.Context, data interface{}) error { // HTTPApplicationDataPfdsAppIdDelete - func HTTPApplicationDataPfdsAppIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + rsp := producer.HandleApplicationDataPfdsAppIdDelete(c.Params.ByName("appId")) sendResponse(c, rsp) } // HTTPApplicationDataPfdsAppIdGet - func HTTPApplicationDataPfdsAppIdGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + rsp := producer.HandleApplicationDataPfdsAppIdGet(c.Params.ByName("appId")) sendResponse(c, rsp) } // HTTPApplicationDataPfdsAppIdPut - func HTTPApplicationDataPfdsAppIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var pfdDataforApp models.PfdDataForApp if err := getDataFromRequestBody(c, &pfdDataforApp); err != nil { @@ -83,6 +98,11 @@ func HTTPApplicationDataPfdsAppIdPut(c *gin.Context) { // HTTPApplicationDataPfdsGet - func HTTPApplicationDataPfdsGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + query := c.Request.URL.Query() rsp := producer.HandleApplicationDataPfdsGet(query["appId"]) sendResponse(c, rsp) @@ -105,6 +125,11 @@ func HTTPExposureDataSubsToNotifySubIdPut(c *gin.Context) { // HTTPPolicyDataBdtDataBdtReferenceIdDelete - func HTTPPolicyDataBdtDataBdtReferenceIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") @@ -115,6 +140,11 @@ func HTTPPolicyDataBdtDataBdtReferenceIdDelete(c *gin.Context) { // HTTPPolicyDataBdtDataBdtReferenceIdGet - func HTTPPolicyDataBdtDataBdtReferenceIdGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["bdtReferenceId"] = c.Params.ByName("bdtReferenceId") @@ -125,6 +155,11 @@ func HTTPPolicyDataBdtDataBdtReferenceIdGet(c *gin.Context) { // HTTPPolicyDataBdtDataBdtReferenceIdPut - func HTTPPolicyDataBdtDataBdtReferenceIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var bdtData models.BdtData if err := getDataFromRequestBody(c, &bdtData); err != nil { @@ -141,6 +176,11 @@ func HTTPPolicyDataBdtDataBdtReferenceIdPut(c *gin.Context) { // HTTPPolicyDataBdtDataGet - func HTTPPolicyDataBdtDataGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) rsp := producer.HandlePolicyDataBdtDataGet(req) @@ -150,6 +190,11 @@ func HTTPPolicyDataBdtDataGet(c *gin.Context) { // HTTPPolicyDataPlmnsPlmnIdUePolicySetGet - func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["plmnId"] = c.Params.ByName("plmnId") @@ -160,6 +205,11 @@ func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(c *gin.Context) { // HTTPPolicyDataSponsorConnectivityDataSponsorIdGet - func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["sponsorId"] = c.Params.ByName("sponsorId") @@ -170,6 +220,11 @@ func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(c *gin.Context) { // HTTPPolicyDataSubsToNotifyPost - func HTTPPolicyDataSubsToNotifyPost(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var policyDataSubscription models.PolicyDataSubscription if err := getDataFromRequestBody(c, &policyDataSubscription); err != nil { @@ -190,6 +245,11 @@ func HTTPPolicyDataSubsToNotifyPost(c *gin.Context) { // HTTPPolicyDataSubsToNotifySubsIdDelete - func HTTPPolicyDataSubsToNotifySubsIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["subsId"] = c.Params.ByName("subsId") @@ -200,6 +260,11 @@ func HTTPPolicyDataSubsToNotifySubsIdDelete(c *gin.Context) { // HTTPPolicyDataSubsToNotifySubsIdPut - func HTTPPolicyDataSubsToNotifySubsIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var policyDataSubscription models.PolicyDataSubscription if err := getDataFromRequestBody(c, &policyDataSubscription); err != nil { @@ -216,6 +281,11 @@ func HTTPPolicyDataSubsToNotifySubsIdPut(c *gin.Context) { // HTTPPolicyDataUesUeIdAmDataGet - func HTTPPolicyDataUesUeIdAmDataGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -226,6 +296,11 @@ func HTTPPolicyDataUesUeIdAmDataGet(c *gin.Context) { // HTTPPolicyDataUesUeIdOperatorSpecificDataGet - func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -236,6 +311,11 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(c *gin.Context) { // HTTPPolicyDataUesUeIdOperatorSpecificDataPatch - Need to be fixed func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem if err := getDataFromRequestBody(c, &patchItemArray); err != nil { @@ -252,6 +332,11 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(c *gin.Context) { // HTTPPolicyDataUesUeIdOperatorSpecificDataPut - func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var operatorSpecificDataContainerMap map[string]models.OperatorSpecificDataContainer if err := getDataFromRequestBody(c, &operatorSpecificDataContainerMap); err != nil { @@ -268,6 +353,11 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(c *gin.Context) { // HTTPPolicyDataUesUeIdSmDataGet - func HTTPPolicyDataUesUeIdSmDataGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -278,6 +368,11 @@ func HTTPPolicyDataUesUeIdSmDataGet(c *gin.Context) { // HTTPPolicyDataUesUeIdSmDataPatch - Need to be fixed func HTTPPolicyDataUesUeIdSmDataPatch(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var usageMonDataMap map[string]models.UsageMonData if err := getDataFromRequestBody(c, &usageMonDataMap); err != nil { @@ -294,6 +389,11 @@ func HTTPPolicyDataUesUeIdSmDataPatch(c *gin.Context) { // HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete - func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["usageMonId"] = c.Params.ByName("usageMonId") @@ -305,6 +405,11 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(c *gin.Context) { // HTTPPolicyDataUesUeIdSmDataUsageMonIdGet - func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["usageMonId"] = c.Params.ByName("usageMonId") @@ -316,6 +421,10 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(c *gin.Context) { // HTTPPolicyDataUesUeIdSmDataUsageMonIdPut - func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } var usageMonData models.UsageMonData if err := getDataFromRequestBody(c, &usageMonData); err != nil { @@ -333,6 +442,11 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(c *gin.Context) { // HTTPPolicyDataUesUeIdUePolicySetGet - func HTTPPolicyDataUesUeIdUePolicySetGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -343,6 +457,11 @@ func HTTPPolicyDataUesUeIdUePolicySetGet(c *gin.Context) { // HTTPPolicyDataUesUeIdUePolicySetPatch - func HTTPPolicyDataUesUeIdUePolicySetPatch(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var uePolicySet models.UePolicySet if err := getDataFromRequestBody(c, &uePolicySet); err != nil { @@ -359,6 +478,10 @@ func HTTPPolicyDataUesUeIdUePolicySetPatch(c *gin.Context) { // HTTPPolicyDataUesUeIdUePolicySetPut - func HTTPPolicyDataUesUeIdUePolicySetPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } var uePolicySet models.UePolicySet if err := getDataFromRequestBody(c, &uePolicySet); err != nil { diff --git a/internal/sbi/datarepository/api_event_amf_subscription_info_document.go b/internal/sbi/datarepository/api_event_amf_subscription_info_document.go index 75c1d2f..ea1f4f6 100644 --- a/internal/sbi/datarepository/api_event_amf_subscription_info_document.go +++ b/internal/sbi/datarepository/api_event_amf_subscription_info_document.go @@ -23,6 +23,10 @@ import ( // HTTPCreateAMFSubscriptions - Creates AMF Subscription Info for an eeSubscription func HTTPCreateAMFSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } var amfSubscriptionInfoArray []models.AmfSubscriptionInfo requestBody, err := c.GetRawData() @@ -73,6 +77,11 @@ func HTTPCreateAMFSubscriptions(c *gin.Context) { // HTTPRemoveAmfSubscriptionsInfo - Deletes AMF Subscription Info for an eeSubscription func HTTPRemoveAmfSubscriptionsInfo(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["subsId"] = c.Params.ByName("subsId") diff --git a/internal/sbi/datarepository/api_event_exposure_data_document.go b/internal/sbi/datarepository/api_event_exposure_data_document.go index 8d1b9ae..90276d9 100644 --- a/internal/sbi/datarepository/api_event_exposure_data_document.go +++ b/internal/sbi/datarepository/api_event_exposure_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQueryEEData - Retrieves the ee profile data of a UE func HTTPQueryEEData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_event_exposure_group_subscription_document.go b/internal/sbi/datarepository/api_event_exposure_group_subscription_document.go index 3981839..a3cd14d 100644 --- a/internal/sbi/datarepository/api_event_exposure_group_subscription_document.go +++ b/internal/sbi/datarepository/api_event_exposure_group_subscription_document.go @@ -23,6 +23,11 @@ import ( // HTTPRemoveEeGroupSubscriptions - Deletes a eeSubscription for a group of UEs or any UE func HTTPRemoveEeGroupSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueGroupId"] = c.Params.ByName("ueGroupId") req.Params["subsId"] = c.Params.ByName("subsId") @@ -45,6 +50,11 @@ func HTTPRemoveEeGroupSubscriptions(c *gin.Context) { // HTTPUpdateEeGroupSubscriptions - Stores an individual ee subscription of a group of UEs or any UE func HTTPUpdateEeGroupSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var eeSubscription models.EeSubscription requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_event_exposure_group_subscriptions_collection.go b/internal/sbi/datarepository/api_event_exposure_group_subscriptions_collection.go index 9b00961..fbda27d 100644 --- a/internal/sbi/datarepository/api_event_exposure_group_subscriptions_collection.go +++ b/internal/sbi/datarepository/api_event_exposure_group_subscriptions_collection.go @@ -23,6 +23,11 @@ import ( // HTTPCreateEeGroupSubscriptions - Create individual EE subscription for a group of UEs or any UE func HTTPCreateEeGroupSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var eeSubscription models.EeSubscription requestBody, err := c.GetRawData() if err != nil { @@ -71,6 +76,11 @@ func HTTPCreateEeGroupSubscriptions(c *gin.Context) { // HTTPQueryEeGroupSubscriptions - Retrieves the ee subscriptions of a group of UEs or any UE func HTTPQueryEeGroupSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueGroupId"] = c.Params.ByName("ueGroupId") diff --git a/internal/sbi/datarepository/api_event_exposure_subscription_document.go b/internal/sbi/datarepository/api_event_exposure_subscription_document.go index cefe7e2..0eb4e4a 100644 --- a/internal/sbi/datarepository/api_event_exposure_subscription_document.go +++ b/internal/sbi/datarepository/api_event_exposure_subscription_document.go @@ -23,6 +23,11 @@ import ( // HTTPRemoveeeSubscriptions - Deletes a eeSubscription func HTTPRemoveeeSubscriptions(c *gin.Context) { + auth_arr := authorizationCheck(c) + if auth_arr != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["subsId"] = c.Params.ByName("subsId") @@ -45,6 +50,11 @@ func HTTPRemoveeeSubscriptions(c *gin.Context) { // HTTPUpdateEesubscriptions - Stores an individual ee subscriptions of a UE func HTTPUpdateEesubscriptions(c *gin.Context) { + auth_arr := authorizationCheck(c) + if auth_arr != nil { + return + } + var eeSubscription models.EeSubscription requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_event_exposure_subscriptions_collection.go b/internal/sbi/datarepository/api_event_exposure_subscriptions_collection.go index 0ac1de3..1f81532 100644 --- a/internal/sbi/datarepository/api_event_exposure_subscriptions_collection.go +++ b/internal/sbi/datarepository/api_event_exposure_subscriptions_collection.go @@ -23,6 +23,11 @@ import ( // HTTPCreateEeSubscriptions - Create individual EE subscription func HTTPCreateEeSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var eeSubscription models.EeSubscription requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateEeSubscriptions(c *gin.Context) { // HTTPQueryeesubscriptions - Retrieves the ee subscriptions of a UE func HTTPQueryeesubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueGroupId"] = c.Params.ByName("ueGroupId") diff --git a/internal/sbi/datarepository/api_individual_influence_data_document.go b/internal/sbi/datarepository/api_individual_influence_data_document.go index 06fc18a..0e9a5d8 100644 --- a/internal/sbi/datarepository/api_individual_influence_data_document.go +++ b/internal/sbi/datarepository/api_individual_influence_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPApplicationDataInfluenceDataInfluenceIdDelete - Delete an individual Influence Data resource func HTTPApplicationDataInfluenceDataInfluenceIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // New HTTP request req := httpwrapper.NewRequest(c.Request, nil) req.Params["influenceId"] = c.Params.ByName("influenceId") @@ -57,6 +62,11 @@ func HTTPApplicationDataInfluenceDataInfluenceIdPatch(c *gin.Context) { // HTTPApplicationDataInfluenceDataInfluenceIdPut - Create or update an individual Influence Data resource func HTTPApplicationDataInfluenceDataInfluenceIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // Get HTTP request body requestBody, err := c.GetRawData() if err != nil { diff --git a/internal/sbi/datarepository/api_individual_influence_data_subscription_document.go b/internal/sbi/datarepository/api_individual_influence_data_subscription_document.go index 4235d61..432c4dd 100644 --- a/internal/sbi/datarepository/api_individual_influence_data_subscription_document.go +++ b/internal/sbi/datarepository/api_individual_influence_data_subscription_document.go @@ -23,6 +23,11 @@ import ( // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete - func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // New HTTP request req := httpwrapper.NewRequest(c.Request, nil) req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") @@ -51,6 +56,11 @@ func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c *gin.Con // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet - func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // New HTTP request req := httpwrapper.NewRequest(c.Request, nil) req.Params["subscriptionId"] = c.Params.ByName("subscriptionId") @@ -75,6 +85,11 @@ func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c *gin.Contex // HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut - func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // Get HTTP request body requestBody, err := c.GetRawData() if err != nil { diff --git a/internal/sbi/datarepository/api_influence_data.go b/internal/sbi/datarepository/api_influence_data.go index bc27e10..a56a9e0 100644 --- a/internal/sbi/datarepository/api_influence_data.go +++ b/internal/sbi/datarepository/api_influence_data.go @@ -23,6 +23,11 @@ import ( // HTTPApplicationDataInfluenceDataGet - func HTTPApplicationDataInfluenceDataGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Query["influence-Ids"] = c.QueryArray("influence-Ids") req.Query["dnns"] = c.QueryArray("dnns") diff --git a/internal/sbi/datarepository/api_influence_data_subscriptions_collection.go b/internal/sbi/datarepository/api_influence_data_subscriptions_collection.go index 4e513f5..9902b7e 100644 --- a/internal/sbi/datarepository/api_influence_data_subscriptions_collection.go +++ b/internal/sbi/datarepository/api_influence_data_subscriptions_collection.go @@ -23,6 +23,11 @@ import ( // HTTPApplicationDataInfluenceDataSubsToNotifyGet - func HTTPApplicationDataInfluenceDataSubsToNotifyGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // New HTTP request req := httpwrapper.NewRequest(c.Request, nil) req.Query["dnn"] = c.QueryArray("dnn") @@ -50,6 +55,11 @@ func HTTPApplicationDataInfluenceDataSubsToNotifyGet(c *gin.Context) { // HTTPApplicationDataInfluenceDataSubsToNotifyPost - func HTTPApplicationDataInfluenceDataSubsToNotifyPost(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + // Get HTTP request body requestBody, err := c.GetRawData() if err != nil { diff --git a/internal/sbi/datarepository/api_operator_specific_data_container_document.go b/internal/sbi/datarepository/api_operator_specific_data_container_document.go index 5af79db..bcfdb46 100644 --- a/internal/sbi/datarepository/api_operator_specific_data_container_document.go +++ b/internal/sbi/datarepository/api_operator_specific_data_container_document.go @@ -23,6 +23,11 @@ import ( // HTTPAmfContext3gpp - To modify operator specific data of a UE func HTTPPatchOperSpecData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPPatchOperSpecData(c *gin.Context) { // HTTPQueryOperSpecData - Retrieves the operator specific data of a UE func HTTPQueryOperSpecData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_parameter_provision_document.go b/internal/sbi/datarepository/api_parameter_provision_document.go index e69887b..308cff6 100644 --- a/internal/sbi/datarepository/api_parameter_provision_document.go +++ b/internal/sbi/datarepository/api_parameter_provision_document.go @@ -23,6 +23,11 @@ import ( // HTTPGetppData - Read the profile of a given UE func HTTPGetppData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_provisioned_data_document.go b/internal/sbi/datarepository/api_provisioned_data_document.go index 881569b..8570acd 100644 --- a/internal/sbi/datarepository/api_provisioned_data_document.go +++ b/internal/sbi/datarepository/api_provisioned_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQueryProvisionedData - Retrieve multiple provisioned data sets of a UE func HTTPQueryProvisionedData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_provisioned_parameter_data_document.go b/internal/sbi/datarepository/api_provisioned_parameter_data_document.go index 0f670b0..0baab70 100644 --- a/internal/sbi/datarepository/api_provisioned_parameter_data_document.go +++ b/internal/sbi/datarepository/api_provisioned_parameter_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPModifyPpData - modify the provisioned parameter data func HTTPModifyPpData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var patchItemArray []models.PatchItem requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_query_amf_subscription_info_document.go b/internal/sbi/datarepository/api_query_amf_subscription_info_document.go index cd81f4c..9282db5 100644 --- a/internal/sbi/datarepository/api_query_amf_subscription_info_document.go +++ b/internal/sbi/datarepository/api_query_amf_subscription_info_document.go @@ -23,6 +23,11 @@ import ( // HTTPGetAmfSubscriptionInfo - Retrieve AMF subscription Info func HTTPGetAmfSubscriptionInfo(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["subsId"] = c.Params.ByName("subsId") diff --git a/internal/sbi/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go b/internal/sbi/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go index 287da38..1026200 100644 --- a/internal/sbi/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go +++ b/internal/sbi/datarepository/api_query_identity_data_by_supi_or_gpsi_document.go @@ -23,6 +23,11 @@ import ( // HTTPGetIdentityData - Retrieve identity data by SUPI or GPSI func HTTPGetIdentityData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go b/internal/sbi/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go index d743ddc..c43e154 100644 --- a/internal/sbi/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go +++ b/internal/sbi/datarepository/api_query_odb_data_by_supi_or_gpsi_document.go @@ -23,6 +23,11 @@ import ( // HTTPGetOdbData - Retrieve ODB Data data by SUPI or GPSI func HTTPGetOdbData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_retrieval_of_shared_data.go b/internal/sbi/datarepository/api_retrieval_of_shared_data.go index 2c67766..af95604 100644 --- a/internal/sbi/datarepository/api_retrieval_of_shared_data.go +++ b/internal/sbi/datarepository/api_retrieval_of_shared_data.go @@ -23,6 +23,11 @@ import ( // HTTPGetSharedData - retrieve shared data func HTTPGetSharedData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + sharedDataIdArray := c.QueryArray("shared-data-ids") req := httpwrapper.NewRequest(c.Request, nil) req.Query["sharedDataIds"] = sharedDataIdArray diff --git a/internal/sbi/datarepository/api_sdm_subscription_document.go b/internal/sbi/datarepository/api_sdm_subscription_document.go index 26347c6..fed5229 100644 --- a/internal/sbi/datarepository/api_sdm_subscription_document.go +++ b/internal/sbi/datarepository/api_sdm_subscription_document.go @@ -23,6 +23,11 @@ import ( // HTTPRemovesdmSubscriptions - Deletes a sdmsubscriptions func HTTPRemovesdmSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["subsId"] = c.Params.ByName("subsId") @@ -45,6 +50,11 @@ func HTTPRemovesdmSubscriptions(c *gin.Context) { // HTTPUpdatesdmsubscriptions - Stores an individual sdm subscriptions of a UE func HTTPUpdatesdmsubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var sdmSubscription models.SdmSubscription requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_sdm_subscriptions_collection.go b/internal/sbi/datarepository/api_sdm_subscriptions_collection.go index 3196fe2..218ee4e 100644 --- a/internal/sbi/datarepository/api_sdm_subscriptions_collection.go +++ b/internal/sbi/datarepository/api_sdm_subscriptions_collection.go @@ -23,6 +23,11 @@ import ( // HTTPCreateSdmSubscriptions - Create individual sdm subscription func HTTPCreateSdmSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var sdmSubscription models.SdmSubscription requestBody, err := c.GetRawData() @@ -75,6 +80,11 @@ func HTTPCreateSdmSubscriptions(c *gin.Context) { // HTTPQuerysdmsubscriptions - Retrieves the sdm subscriptions of a UE func HTTPQuerysdmsubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_session_management_subscription_data.go b/internal/sbi/datarepository/api_session_management_subscription_data.go index 624bfdf..208c5d6 100644 --- a/internal/sbi/datarepository/api_session_management_subscription_data.go +++ b/internal/sbi/datarepository/api_session_management_subscription_data.go @@ -23,6 +23,11 @@ import ( // HTTPQuerySmData - Retrieves the Session Management subscription data of a UE func HTTPQuerySmData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_smf_registration_document.go b/internal/sbi/datarepository/api_smf_registration_document.go index 5bb269d..a5fa7ad 100644 --- a/internal/sbi/datarepository/api_smf_registration_document.go +++ b/internal/sbi/datarepository/api_smf_registration_document.go @@ -23,6 +23,11 @@ import ( // HTTPCreateSmfContextNon3gpp - To create an individual SMF context data of a UE in the UDR func HTTPCreateSmfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var smfRegistration models.SmfRegistration requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateSmfContextNon3gpp(c *gin.Context) { // HTTPDeleteSmfContext - To remove an individual SMF context data of a UE the UDR func HTTPDeleteSmfContext(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") @@ -94,6 +104,11 @@ func HTTPDeleteSmfContext(c *gin.Context) { // HTTPQuerySmfRegistration - Retrieves the individual SMF registration of a UE func HTTPQuerySmfRegistration(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["pduSessionId"] = c.Params.ByName("pduSessionId") diff --git a/internal/sbi/datarepository/api_smf_registrations_collection.go b/internal/sbi/datarepository/api_smf_registrations_collection.go index ca2cec6..878dc44 100644 --- a/internal/sbi/datarepository/api_smf_registrations_collection.go +++ b/internal/sbi/datarepository/api_smf_registrations_collection.go @@ -23,6 +23,11 @@ import ( // HTTPQuerySmfRegList - Retrieves the SMF registration list of a UE func HTTPQuerySmfRegList(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_smf_selection_subscription_data_document.go b/internal/sbi/datarepository/api_smf_selection_subscription_data_document.go index f643ca1..1fe086d 100644 --- a/internal/sbi/datarepository/api_smf_selection_subscription_data_document.go +++ b/internal/sbi/datarepository/api_smf_selection_subscription_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQuerySmfSelectData - Retrieves the SMF selection subscription data of a UE func HTTPQuerySmfSelectData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_sms_management_subscription_data_document.go b/internal/sbi/datarepository/api_sms_management_subscription_data_document.go index 8476038..55c2b1d 100644 --- a/internal/sbi/datarepository/api_sms_management_subscription_data_document.go +++ b/internal/sbi/datarepository/api_sms_management_subscription_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQuerySmsMngData - Retrieves the SMS management subscription data of a UE func HTTPQuerySmsMngData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_sms_subscription_data_document.go b/internal/sbi/datarepository/api_sms_subscription_data_document.go index 9355c05..4bd3410 100644 --- a/internal/sbi/datarepository/api_sms_subscription_data_document.go +++ b/internal/sbi/datarepository/api_sms_subscription_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQuerySmsData - Retrieves the SMS subscription data of a UE func HTTPQuerySmsData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/api_smsf3_gpp_registration_document.go b/internal/sbi/datarepository/api_smsf3_gpp_registration_document.go index 52356b1..f6ab34e 100644 --- a/internal/sbi/datarepository/api_smsf3_gpp_registration_document.go +++ b/internal/sbi/datarepository/api_smsf3_gpp_registration_document.go @@ -23,6 +23,11 @@ import ( // HTTPCreateSmsfContext3gpp - Create the SMSF context data of a UE via 3GPP access func HTTPCreateSmsfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var smsfRegistration models.SmsfRegistration requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateSmsfContext3gpp(c *gin.Context) { // HTTPDeleteSmsfContext3gpp - To remove the SMSF context data of a UE via 3GPP access func HTTPDeleteSmsfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -93,6 +103,11 @@ func HTTPDeleteSmsfContext3gpp(c *gin.Context) { // HTTPQuerySmsfContext3gpp - Retrieves the SMSF context data of a UE using 3gpp access func HTTPQuerySmsfContext3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_smsf_non3_gpp_registration_document.go b/internal/sbi/datarepository/api_smsf_non3_gpp_registration_document.go index 76b5df2..7380c2d 100644 --- a/internal/sbi/datarepository/api_smsf_non3_gpp_registration_document.go +++ b/internal/sbi/datarepository/api_smsf_non3_gpp_registration_document.go @@ -23,6 +23,11 @@ import ( // HTTPCreateSmsfContextNon3gpp - Create the SMSF context data of a UE via non-3GPP access func HTTPCreateSmsfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var smsfRegistration models.SmsfRegistration requestBody, err := c.GetRawData() @@ -72,6 +77,11 @@ func HTTPCreateSmsfContextNon3gpp(c *gin.Context) { // HTTPDeleteSmsfContextNon3gpp - To remove the SMSF context data of a UE via non-3GPP access func HTTPDeleteSmsfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") @@ -93,6 +103,11 @@ func HTTPDeleteSmsfContextNon3gpp(c *gin.Context) { // HTTPQuerySmsfContextNon3gpp - Retrieves the SMSF context data of a UE using non-3gpp access func HTTPQuerySmsfContextNon3gpp(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_subs_to_notify_collection.go b/internal/sbi/datarepository/api_subs_to_notify_collection.go index bf1fb8f..ccd7b6b 100644 --- a/internal/sbi/datarepository/api_subs_to_notify_collection.go +++ b/internal/sbi/datarepository/api_subs_to_notify_collection.go @@ -23,6 +23,11 @@ import ( // HTTPPostSubscriptionDataSubscriptions - Subscription data subscriptions func HTTPPostSubscriptionDataSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + var subscriptionDataSubscriptions models.SubscriptionDataSubscriptions requestBody, err := c.GetRawData() diff --git a/internal/sbi/datarepository/api_subs_to_notify_document.go b/internal/sbi/datarepository/api_subs_to_notify_document.go index 9af75e9..62e7252 100644 --- a/internal/sbi/datarepository/api_subs_to_notify_document.go +++ b/internal/sbi/datarepository/api_subs_to_notify_document.go @@ -23,6 +23,11 @@ import ( // HTTPRemovesubscriptionDataSubscriptions - Deletes a subscriptionDataSubscriptions func HTTPRemovesubscriptionDataSubscriptions(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") diff --git a/internal/sbi/datarepository/api_trace_data_document.go b/internal/sbi/datarepository/api_trace_data_document.go index 5eb2174..a98724d 100644 --- a/internal/sbi/datarepository/api_trace_data_document.go +++ b/internal/sbi/datarepository/api_trace_data_document.go @@ -23,6 +23,11 @@ import ( // HTTPQueryTraceData - Retrieves the trace configuration data of a UE func HTTPQueryTraceData(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + req := httpwrapper.NewRequest(c.Request, nil) req.Params["ueId"] = c.Params.ByName("ueId") req.Params["servingPlmnId"] = c.Params.ByName("servingPlmnId") diff --git a/internal/sbi/datarepository/routers.go b/internal/sbi/datarepository/routers.go index 645e601..6261d3d 100644 --- a/internal/sbi/datarepository/routers.go +++ b/internal/sbi/datarepository/routers.go @@ -15,6 +15,7 @@ import ( "github.com/gin-gonic/gin" + "github.com/free5gc/openapi" "github.com/free5gc/udr/internal/logger" "github.com/free5gc/udr/pkg/factory" logger_util "github.com/free5gc/util/logger" @@ -32,6 +33,23 @@ type Route struct { HandlerFunc gin.HandlerFunc } +func authorizationCheck(c *gin.Context) error { + if factory.UdrConfig.GetOAuth() { + oauth_err := openapi.VerifyOAuth(c.Request.Header.Get("Authorization"), "nudr-dr", + factory.UdrConfig.GetNrfCertPemPath()) + if oauth_err != nil { + c.JSON(http.StatusUnauthorized, gin.H{"error": oauth_err.Error()}) + return oauth_err + } + } + allowNf_err := factory.UdrConfig.VerifyServiceAllowType(c.Request.Header.Get("requestNF"), "nudr-dr") + if allowNf_err != nil { + c.JSON(http.StatusUnauthorized, gin.H{"error": allowNf_err.Error()}) + return allowNf_err + } + return nil +} + // Routes is the list of the generated Route. type Routes []Route @@ -199,6 +217,11 @@ func Index(c *gin.Context) { // HandleAppDataInfluDataSubsToNotifyConflictDelete filters invalid requested resource on subs-to-notify DELETE func HandleAppDataInfluDataSubsToNotifyConflictDelete(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + influenceId := c.Param("influenceId") if influenceId == "subs-to-notify" { HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c) @@ -209,6 +232,11 @@ func HandleAppDataInfluDataSubsToNotifyConflictDelete(c *gin.Context) { // HandleAppDataInfluDataSubsToNotifyConflictGet filters invalid requested resource on subs-to-notify GET func HandleAppDataInfluDataSubsToNotifyConflictGet(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + influenceId := c.Param("influenceId") if influenceId == "subs-to-notify" { HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c) @@ -219,6 +247,11 @@ func HandleAppDataInfluDataSubsToNotifyConflictGet(c *gin.Context) { // HandleAppDataInfluDataSubsToNotifyConflictPut filters invalid requested resource on subs-to-notify PUT func HandleAppDataInfluDataSubsToNotifyConflictPut(c *gin.Context) { + auth_err := authorizationCheck(c) + if auth_err != nil { + return + } + influenceId := c.Param("influenceId") if influenceId == "subs-to-notify" { HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(c)