Skip to content

Commit 17086d8

Browse files
MPA: Add ability to pass cred source to MPA command printed for approver (#600)
* Add ability to pass cred source to MPA command printed for approver * revert * Revert credential source
1 parent 8f67d19 commit 17086d8

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

cmd/sanssh/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ func Run(ctx context.Context, rs RunState) {
390390
}
391391

392392
state.Conn = conn
393+
state.CredSource = rs.CredSource
393394
state.Out = output[start:end]
394395
state.Err = errors[start:end]
395396
if len(rs.Targets) == 0 {

services/mpa/mpahooks/mpahooks.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func createAndBlockOnProxiedMPA(ctx context.Context, method string, args any, co
279279

280280
if len(targetsNeedingApproval) > 0 {
281281
fmt.Fprintln(os.Stderr, "Waiting for multi-party approval on all targets, ask an approver to run:")
282-
fmt.Fprintf(os.Stderr, " sanssh -proxy %v -targets %v mpa approve %v\n", conn.Proxy().Target(), strings.Join(targetsNeedingApproval, ","), mpaID)
282+
fmt.Fprintf(os.Stderr, " sanssh %v-proxy %v -targets %v mpa approve %v\n", getSourceParam(state.CredSource), conn.Proxy().Target(), strings.Join(targetsNeedingApproval, ","), mpaID)
283283
// We call WaitForApproval on all targets, even ones already approved. This is silly but not harmful.
284284
waitCh, err := mpaClient.WaitForApprovalOneMany(ctx, &mpa.WaitForApprovalRequest{Id: mpaID})
285285
if err != nil {
@@ -294,6 +294,13 @@ func createAndBlockOnProxiedMPA(ctx context.Context, method string, args any, co
294294
return mpaID, nil
295295
}
296296

297+
func getSourceParam(credentialSource string) string {
298+
if credentialSource != "" {
299+
return fmt.Sprintf("--credential-source %s ", credentialSource)
300+
}
301+
return ""
302+
}
303+
297304
// ProxyClientUnaryInterceptor will perform the MPA flow prior to making the desired RPC
298305
// calls through the proxy.
299306
func ProxyClientUnaryInterceptor(state *util.ExecuteState) proxy.UnaryInterceptor {

services/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ type ExecuteState struct {
5050
Out []io.Writer
5151
// Error stream to write log lines related to particular target host.
5252
Err []io.Writer
53+
// CredSource is the credential source to use for authn.
54+
CredSource string
5355
}
5456

5557
// StreamingChunkSize is the chunk size we use when sending replies on a stream.

0 commit comments

Comments
 (0)