Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/kube-tarian/kad into featur…
Browse files Browse the repository at this point in the history
…e/cluster_claim
  • Loading branch information
anil-sarodh committed Jan 13, 2024
2 parents 9d60fb2 + 51cfe1b commit 1d63403
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/pkg/api/configure_app_sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s *Server) configureSSOForClusterApps(ctx context.Context, orgId, clusterI
appClientName := fmt.Sprintf("%s-%s", clusterID, app.ReleaseName)
s.log.Infof("Register app %s as app-client %s with IAM, clusterId: %s, [org: %s]",
app.ReleaseName, appClientName, clusterID, orgId)
clientID, clientSecret, err := s.iam.RegisterAppClientSecrets(ctx, appClientName, app.LaunchURL)
clientID, clientSecret, err := s.iam.RegisterAppClientSecrets(ctx, appClientName, app.LaunchURL, orgId)
if err != nil {
return errors.WithMessagef(err, "failed to register app %s on cluster %s with IAM", app.ReleaseName, clusterID)
}
Expand Down
10 changes: 7 additions & 3 deletions server/pkg/iam-client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type IAMRegister interface {
RegisterAppClientSecrets(ctx context.Context, clientName, redirectURL string) (string, string, error)
RegisterAppClientSecrets(ctx context.Context, clientName, redirectURL, organisationid string) (string, string, error)
GetOAuthURL() string
}

Expand Down Expand Up @@ -87,15 +87,19 @@ func (c *Client) GetOAuthURL() string {
return c.oryClient.GetURL()
}

func (c *Client) RegisterAppClientSecrets(ctx context.Context, clientName, redirectURL string) (string, string, error) {
func (c *Client) RegisterAppClientSecrets(ctx context.Context, clientName, redirectURL, organisationid string) (string, string, error) {
conn, err := grpc.Dial(c.cfg.IAMURL, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return "", "", err
}
defer conn.Close()

iamclient := iampb.NewOauthServiceClient(conn)
res, err := iamclient.CreateOauthClient(context.Background(), &iampb.OauthClientRequest{
md := metadata.Pairs(
"organisationid", organisationid,
)
newCtx := metadata.NewOutgoingContext(ctx, md)
res, err := iamclient.CreateOauthClient(newCtx, &iampb.OauthClientRequest{
ClientName: clientName, RedirectUris: []string{redirectURL},
})
if err != nil {
Expand Down

0 comments on commit 1d63403

Please sign in to comment.