Skip to content

Commit

Permalink
add targetNF param for GetTokenCtx()
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 committed Oct 27, 2023
1 parent d6ce425 commit 6ff4794
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/sbi/consumer/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NfT
configuration := Nnrf_NFDiscovery.NewConfiguration()
configuration.SetBasePath(nrfUri)
client := Nnrf_NFDiscovery.NewAPIClient(configuration)
ctx, _, err := GetTokenCtx("nnrf-disc")
ctx, _, err := GetTokenCtx("nnrf-disc", "NRF")
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/sbi/consumer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"golang.org/x/oauth2"
)

func GetTokenCtx(scope string) (context.Context, *models.ProblemDetails, error) {
func GetTokenCtx(scope, targetNF string) (context.Context, *models.ProblemDetails, error) {
if factory.AusfConfig.GetOAuth() {
tok, pd, err := sendAccTokenReq(scope)
tok, pd, err := sendAccTokenReq(scope, targetNF)
if err != nil {
return nil, pd, err
}
Expand All @@ -30,7 +30,7 @@ func GetTokenCtx(scope string) (context.Context, *models.ProblemDetails, error)
return context.TODO(), nil, nil
}

func sendAccTokenReq(scope string) (oauth2.TokenSource, *models.ProblemDetails, error) {
func sendAccTokenReq(scope, targetNF string) (oauth2.TokenSource, *models.ProblemDetails, error) {
logger.ConsumerLog.Infof("Send Access Token Request")
var client *Nnrf_AccessToken.APIClient
ausfSelf := ausf_context.GetSelf()
Expand Down Expand Up @@ -62,7 +62,7 @@ func sendAccTokenReq(scope string) (oauth2.TokenSource, *models.ProblemDetails,
tok, res, err := client.AccessTokenRequestApi.AccessTokenRequest(context.Background(), "client_credentials",
ausfSelf.NfId, scope, &Nnrf_AccessToken.AccessTokenRequestParamOpts{
NfType: optional.NewInterface(models.NfType_AUSF),
TargetNfType: optional.NewInterface(models.NfType_NRF),
TargetNfType: optional.NewInterface(targetNF),
})
if err == nil {
ausfSelf.TokenMap.Store(scope, tok)
Expand Down Expand Up @@ -149,7 +149,7 @@ func SendRegisterNFInstance(nrfUri, nfInstanceId string, profile models.NfProfil

func SendDeregisterNFInstance() (*models.ProblemDetails, error) {
logger.ConsumerLog.Infof("Send Deregister NFInstance")
ctx, pd, err := GetTokenCtx("nnrf-nfm")
ctx, pd, err := GetTokenCtx("nnrf-nfm", "NRF")
if err != nil {
return pd, err
}
Expand Down

0 comments on commit 6ff4794

Please sign in to comment.