Skip to content

Commit

Permalink
Refactor: Move authorization return context logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Dec 24, 2023
1 parent 82a4028 commit 7ae12a0
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPQueryAmData(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPAmfContext3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -79,6 +80,7 @@ func HTTPAmfContext3gpp(c *gin.Context) {
func HTTPCreateAmfContext3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -133,6 +135,7 @@ func HTTPCreateAmfContext3gpp(c *gin.Context) {
func HTTPQueryAmfContext3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPAmfContextNon3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -79,6 +80,7 @@ func HTTPAmfContextNon3gpp(c *gin.Context) {
func HTTPCreateAmfContextNon3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -133,6 +135,7 @@ func HTTPCreateAmfContextNon3gpp(c *gin.Context) {
func HTTPQueryAmfContextNon3gpp(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPModifyAmfSubscriptionInfo(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPModifyAuthentication(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -79,6 +80,7 @@ func HTTPModifyAuthentication(c *gin.Context) {
func HTTPQueryAuthSubsData(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPCreateAuthenticationSoR(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -79,6 +80,7 @@ func HTTPCreateAuthenticationSoR(c *gin.Context) {
func HTTPQueryAuthSoR(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPCreateAuthenticationStatus(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -79,6 +80,7 @@ func HTTPCreateAuthenticationStatus(c *gin.Context) {
func HTTPQueryAuthenticationStatus(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
27 changes: 27 additions & 0 deletions internal/sbi/datarepository/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func getDataFromRequestBody(c *gin.Context, data interface{}) error {
func HTTPApplicationDataPfdsAppIdDelete(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -71,6 +72,7 @@ func HTTPApplicationDataPfdsAppIdDelete(c *gin.Context) {
func HTTPApplicationDataPfdsAppIdGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -82,6 +84,7 @@ func HTTPApplicationDataPfdsAppIdGet(c *gin.Context) {
func HTTPApplicationDataPfdsAppIdPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -100,6 +103,7 @@ func HTTPApplicationDataPfdsAppIdPut(c *gin.Context) {
func HTTPApplicationDataPfdsGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -127,6 +131,7 @@ func HTTPExposureDataSubsToNotifySubIdPut(c *gin.Context) {
func HTTPPolicyDataBdtDataBdtReferenceIdDelete(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -142,6 +147,7 @@ func HTTPPolicyDataBdtDataBdtReferenceIdDelete(c *gin.Context) {
func HTTPPolicyDataBdtDataBdtReferenceIdGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -157,6 +163,7 @@ func HTTPPolicyDataBdtDataBdtReferenceIdGet(c *gin.Context) {
func HTTPPolicyDataBdtDataBdtReferenceIdPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -178,6 +185,7 @@ func HTTPPolicyDataBdtDataBdtReferenceIdPut(c *gin.Context) {
func HTTPPolicyDataBdtDataGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -192,6 +200,7 @@ func HTTPPolicyDataBdtDataGet(c *gin.Context) {
func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -207,6 +216,7 @@ func HTTPPolicyDataPlmnsPlmnIdUePolicySetGet(c *gin.Context) {
func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -222,6 +232,7 @@ func HTTPPolicyDataSponsorConnectivityDataSponsorIdGet(c *gin.Context) {
func HTTPPolicyDataSubsToNotifyPost(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -247,6 +258,7 @@ func HTTPPolicyDataSubsToNotifyPost(c *gin.Context) {
func HTTPPolicyDataSubsToNotifySubsIdDelete(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -262,6 +274,7 @@ func HTTPPolicyDataSubsToNotifySubsIdDelete(c *gin.Context) {
func HTTPPolicyDataSubsToNotifySubsIdPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -283,6 +296,7 @@ func HTTPPolicyDataSubsToNotifySubsIdPut(c *gin.Context) {
func HTTPPolicyDataUesUeIdAmDataGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -298,6 +312,7 @@ func HTTPPolicyDataUesUeIdAmDataGet(c *gin.Context) {
func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -313,6 +328,7 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataGet(c *gin.Context) {
func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -334,6 +350,7 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataPatch(c *gin.Context) {
func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -355,6 +372,7 @@ func HTTPPolicyDataUesUeIdOperatorSpecificDataPut(c *gin.Context) {
func HTTPPolicyDataUesUeIdSmDataGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -370,6 +388,7 @@ func HTTPPolicyDataUesUeIdSmDataGet(c *gin.Context) {
func HTTPPolicyDataUesUeIdSmDataPatch(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -391,6 +410,7 @@ func HTTPPolicyDataUesUeIdSmDataPatch(c *gin.Context) {
func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -407,6 +427,7 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdDelete(c *gin.Context) {
func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -423,8 +444,10 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdGet(c *gin.Context) {
func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

var usageMonData models.UsageMonData

if err := getDataFromRequestBody(c, &usageMonData); err != nil {
Expand All @@ -444,6 +467,7 @@ func HTTPPolicyDataUesUeIdSmDataUsageMonIdPut(c *gin.Context) {
func HTTPPolicyDataUesUeIdUePolicySetGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -459,6 +483,7 @@ func HTTPPolicyDataUesUeIdUePolicySetGet(c *gin.Context) {
func HTTPPolicyDataUesUeIdUePolicySetPatch(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand All @@ -480,8 +505,10 @@ func HTTPPolicyDataUesUeIdUePolicySetPatch(c *gin.Context) {
func HTTPPolicyDataUesUeIdUePolicySetPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

var uePolicySet models.UePolicySet

if err := getDataFromRequestBody(c, &uePolicySet); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
func HTTPCreateAMFSubscriptions(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

var amfSubscriptionInfoArray []models.AmfSubscriptionInfo

requestBody, err := c.GetRawData()
Expand Down Expand Up @@ -79,6 +81,7 @@ func HTTPCreateAMFSubscriptions(c *gin.Context) {
func HTTPRemoveAmfSubscriptionsInfo(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -58,6 +59,7 @@ func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdDelete(c *gin.Con
func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down Expand Up @@ -87,6 +89,7 @@ func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdGet(c *gin.Contex
func HTTPApplicationDataInfluenceDataSubsToNotifySubscriptionIdPut(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
1 change: 1 addition & 0 deletions internal/sbi/datarepository/api_influence_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPApplicationDataInfluenceDataGet(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPQueryProvisionedData(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
func HTTPGetAmfSubscriptionInfo(c *gin.Context) {
auth_err := authorizationCheck(c)
if auth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()})
return
}

Expand Down
Loading

0 comments on commit 7ae12a0

Please sign in to comment.