As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects

Passing pushauth flag as bool in json body to internal api doesn't become a...

Open Manoj Memana Jayakumar requested to merge mmj/gitlab-shell:506-jsandlin into main
1 file
+ 11
12
Compare changes
  • Side-by-side
  • Inline
@@ -13,6 +13,7 @@ import (
type Command struct {
Config *config.Config
Client *twofactorverify.Client
Args *commandargs.Shell
ReadWriter *readwriter.ReadWriter
}
@@ -24,6 +25,14 @@ type Result struct {
}
func (c *Command) Execute(ctx context.Context) error {
// config.GetHTTPClient isn't thread-safe so save Client in struct for concurrency
// workaround until #518 is fixed
var err error
c.Client, err = twofactorverify.NewClient(c.Config)
if err != nil {
return err
}
verify := make(chan Result)
pushauth := make(chan Result)
@@ -71,14 +80,9 @@ func (c *Command) getOTP() string {
}
func (c *Command) pushAuth(ctx context.Context) (status string, success bool, err error) {
client, err := twofactorverify.NewClient(c.Config)
if err != nil {
return "", false, err
}
reason := ""
success, reason, err = client.PushAuth(ctx, c.Args)
success, reason, err = c.Client.PushAuth(ctx, c.Args)
if success {
status = fmt.Sprintf("\nPush OTP validation successful. Git operations are now allowed.\n")
} else {
@@ -93,14 +97,9 @@ func (c *Command) pushAuth(ctx context.Context) (status string, success bool, er
}
func (c *Command) verifyOTP(ctx context.Context, otp string) (status string, success bool, err error) {
client, err := twofactorverify.NewClient(c.Config)
if err != nil {
return "", false, err
}
reason := ""
success, reason, err = client.VerifyOTP(ctx, c.Args, otp)
success, reason, err = c.Client.VerifyOTP(ctx, c.Args, otp)
if success {
status = fmt.Sprintf("\nOTP validation successful. Git operations are now allowed.\n")
} else {
Loading