Skip to content

Commit abeb350

Browse files
harjas27Harness
authored andcommitted
[fix]:[IDP-6237]: use NG Manager Secret for workflow execution (#205)
* 0f55a0 [feat]:[IDP-6237]: use NG Manager Secret for workflow execution
1 parent 8da5259 commit abeb350

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

client/idp.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"context"
55
"fmt"
66
"log/slog"
7-
"strings"
87

98
"github.com/harness/harness-mcp/client/dto"
9+
"github.com/harness/harness-mcp/pkg/harness/auth"
1010
)
1111

1212
const (
@@ -33,7 +33,8 @@ const (
3333
)
3434

3535
type IDPService struct {
36-
Client *Client
36+
Client *Client
37+
NgManagerAuthProvider auth.Provider
3738
}
3839

3940
func (i *IDPService) GetEntity(ctx context.Context, scope dto.Scope, kind string, identifier string) (*dto.EntityResponse, error) {
@@ -309,17 +310,12 @@ func (i *IDPService) ExecuteWorkflow(ctx context.Context, scope dto.Scope, ident
309310
params := make(map[string]string)
310311
addScope(scope, params)
311312

312-
_, authHeaderVal, err := i.Client.AuthProvider.GetHeader(ctx)
313+
_, authHeaderVal, err := i.NgManagerAuthProvider.GetHeader(ctx)
313314
if err != nil {
314315
slog.Error("Failed to get auth header", "error", err)
315316
return nil, err
316317
}
317-
token := authHeaderVal
318-
parts := strings.Split(authHeaderVal, " ")
319-
if len(parts) == 2 {
320-
token = parts[1]
321-
}
322-
inputSet["token"] = token
318+
inputSet["token"] = authHeaderVal
323319
body := new(dto.ExecuteWorkflowRequest)
324320
body.Identifier = identifier
325321
body.Values = inputSet

pkg/modules/idp.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/harness/harness-mcp/client"
77
"github.com/harness/harness-mcp/cmd/harness-mcp-server/config"
8+
"github.com/harness/harness-mcp/pkg/harness/auth"
89
"github.com/harness/harness-mcp/pkg/harness/tools"
910
"github.com/harness/harness-mcp/pkg/modules/utils"
1011
"github.com/harness/harness-mcp/pkg/toolsets"
@@ -75,8 +76,16 @@ func RegisterInternalDeveloperPortal(config *config.Config, tsg *toolsets.Toolse
7576
return err
7677
}
7778

79+
var ngManagerAuthProvider auth.Provider
80+
if config.Internal {
81+
ngManagerAuthProvider = auth.NewJWTProvider(config.NgManagerSecret, utils.ServiceIdentity, &utils.DefaultJWTLifetime)
82+
} else {
83+
ngManagerAuthProvider = auth.NewAPIKeyProvider(config.APIKey)
84+
}
85+
7886
idpClient := &client.IDPService{
79-
Client: c,
87+
Client: c,
88+
NgManagerAuthProvider: ngManagerAuthProvider,
8089
}
8190

8291
// Get the GenAI client using the shared method

0 commit comments

Comments
 (0)