Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get locationUrl from UDM #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading