Skip to content

Commit

Permalink
fix: get locationUrl from UDM
Browse files Browse the repository at this point in the history
  • Loading branch information
TYuan0816 committed Oct 8, 2024
1 parent 842217c commit ae8599e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 7 additions & 4 deletions internal/sbi/consumer/udm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ func (s *nudmService) GenerateAuthDataApi(
udmUrl string,
supiOrSuci string,
authInfoReq models.AuthenticationInfoRequest,
) (*models.AuthenticationInfoResult, error, *models.ProblemDetails) {
) (*models.AuthenticationInfoResult, string, error, *models.ProblemDetails) {
client := s.getUdmUeauClient(udmUrl)

ctx, pd, err := ausf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_UEAU, models.NfType_UDM)
if err != nil {
return nil, err, pd
return nil, "", err, pd
}

authInfoResult, rsp, err := client.GenerateAuthDataApi.GenerateAuthData(ctx, supiOrSuci, authInfoReq)
Expand All @@ -96,12 +96,15 @@ func (s *nudmService) GenerateAuthDataApi(
problemDetails.Cause = "UPSTREAM_SERVER_ERROR"
}
problemDetails.Status = int32(rsp.StatusCode)
return nil, err, &problemDetails
return nil, "", err, &problemDetails
}
defer func() {
if rspCloseErr := rsp.Body.Close(); rspCloseErr != nil {
logger.UeAuthLog.Errorf("GenerateAuthDataApi response body cannot close: %+v", rspCloseErr)
}
}()
return &authInfoResult, nil, nil

locationUrl := rsp.Header.Get("Location")

return &authInfoResult, locationUrl, nil, nil
}
9 changes: 4 additions & 5 deletions internal/sbi/processor/ue_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (p *Processor) UeAuthPostRequestProcedure(c *gin.Context, updateAuthenticat

udmUrl := p.Consumer().GetUdmUrl(self.NrfUri)

result, err, pd := p.Consumer().GenerateAuthDataApi(udmUrl, supiOrSuci, authInfoReq)
result, locationUrl, err, pd := p.Consumer().GenerateAuthDataApi(udmUrl, supiOrSuci, authInfoReq)
if err != nil {
logger.UeAuthLog.Infof("GenerateAuthDataApi error: %+v", err)
c.JSON(http.StatusInternalServerError, pd)
Expand All @@ -266,14 +266,13 @@ func (p *Processor) UeAuthPostRequestProcedure(c *gin.Context, updateAuthenticat
ausfUeContext := ausf_context.NewAusfUeContext(ueid)
ausfUeContext.ServingNetworkName = snName
ausfUeContext.AuthStatus = models.AuthResult_ONGOING
ausfUeContext.UdmUeauUrl = udmUrl
ausfUeContext.UdmUeauUrl = locationUrl
ausf_context.AddAusfUeContextToPool(ausfUeContext)

logger.UeAuthLog.Infof("Add SuciSupiPair (%s, %s) to map.\n", supiOrSuci, ueid)
ausf_context.AddSuciSupiPairToMap(supiOrSuci, ueid)

locationURI := self.Url + factory.AusfAuthResUriPrefix + "/ue-authentications/" + supiOrSuci
putLink := locationURI
putLink := locationUrl
if authInfoResult.AuthType == models.AuthType__5_G_AKA {
logger.UeAuthLog.Infoln("Use 5G AKA auth method")
putLink += "/5g-aka-confirmation"
Expand Down Expand Up @@ -440,7 +439,7 @@ func (p *Processor) UeAuthPostRequestProcedure(c *gin.Context, updateAuthenticat

responseBody.AuthType = authInfoResult.AuthType

c.Header("Location", locationURI)
c.Header("Location", locationUrl)
c.JSON(http.StatusCreated, responseBody)
}

Expand Down

0 comments on commit ae8599e

Please sign in to comment.