Merge pull request #30 from lenforiee/fix-spelling-mistakes

Fix spelling mistakes in the code
This commit is contained in:
Samuel Lorch 2023-04-20 13:49:15 +02:00 committed by GitHub
commit 488bf7043a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View file

@ -84,7 +84,7 @@ For sharing with groups the `--group` argument exists.
You can setup MFA also using the configuration sub command, only TOTP is supported, there are multiple modes for MFA: `none`, `interactive-totp` and `noninteractive-totp`. You can setup MFA also using the configuration sub command, only TOTP is supported, there are multiple modes for MFA: `none`, `interactive-totp` and `noninteractive-totp`.
| Mode | Description | | Mode | Description |
| --- | --- | | --- | --- |
|`none`|just errors if challanged for MFA. |`none`|just errors if challenged for MFA.
|`interactive-totp` | prompts for interactive entry of TOTP Codes. |`interactive-totp` | prompts for interactive entry of TOTP Codes.
|`noninteractive-totp` | automatically generates TOTP Codes when challenged, it requires the `totpToken` flag to be set to your totp Secret, you can configure the behavior using the `mfaDelay`, `mfaRetrys` and `totpOffset` flags |`noninteractive-totp` | automatically generates TOTP Codes when challenged, it requires the `totpToken` flag to be set to your totp Secret, you can configure the behavior using the `mfaDelay`, `mfaRetrys` and `totpOffset` flags

2
go.mod
View file

@ -4,7 +4,7 @@ go 1.18
require ( require (
github.com/alessio/shellescape v1.4.1 github.com/alessio/shellescape v1.4.1
github.com/passbolt/go-passbolt v0.5.8 github.com/passbolt/go-passbolt v0.6.0
github.com/pterm/pterm v0.12.51 github.com/pterm/pterm v0.12.51
github.com/spf13/cobra v1.6.1 github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.14.0 github.com/spf13/viper v1.14.0

2
go.sum
View file

@ -203,6 +203,8 @@ github.com/passbolt/go-passbolt v0.5.7 h1:qpFZBcuyjcqUqnptnrCYTCOzzjtv7a8qTeohRU
github.com/passbolt/go-passbolt v0.5.7/go.mod h1:drZXAx/5iLqH9MH46HCgy+taTkJ0Akw3igoBV8TnbF4= github.com/passbolt/go-passbolt v0.5.7/go.mod h1:drZXAx/5iLqH9MH46HCgy+taTkJ0Akw3igoBV8TnbF4=
github.com/passbolt/go-passbolt v0.5.8 h1:cKogZ1w2qY/MHdwwG5Ppef+xLoQw+w8djUBCsYvoUw8= github.com/passbolt/go-passbolt v0.5.8 h1:cKogZ1w2qY/MHdwwG5Ppef+xLoQw+w8djUBCsYvoUw8=
github.com/passbolt/go-passbolt v0.5.8/go.mod h1:86tXSTxBwbjg9Qmt2LiTAoMJqIFgHX15BVReRtbKiyE= github.com/passbolt/go-passbolt v0.5.8/go.mod h1:86tXSTxBwbjg9Qmt2LiTAoMJqIFgHX15BVReRtbKiyE=
github.com/passbolt/go-passbolt v0.6.0 h1:qTrFPWwcE6Q8Ss238ph3LortnlPkx0R31WPgmiYrd48=
github.com/passbolt/go-passbolt v0.6.0/go.mod h1:86tXSTxBwbjg9Qmt2LiTAoMJqIFgHX15BVReRtbKiyE=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=

View file

@ -84,12 +84,12 @@ func GetClient(ctx context.Context) (*api.Client, error) {
switch viper.GetString("mfaMode") { switch viper.GetString("mfaMode") {
case "interactive-totp": case "interactive-totp":
client.MFACallback = func(ctx context.Context, c *api.Client, res *api.APIResponse) (http.Cookie, error) { client.MFACallback = func(ctx context.Context, c *api.Client, res *api.APIResponse) (http.Cookie, error) {
challange := api.MFAChallange{} challenge := api.MFAChallenge{}
err := json.Unmarshal(res.Body, &challange) err := json.Unmarshal(res.Body, &challenge)
if err != nil { if err != nil {
return http.Cookie{}, fmt.Errorf("Parsing MFA Challange") return http.Cookie{}, fmt.Errorf("Parsing MFA Challenge")
} }
if challange.Provider.TOTP == "" { if challenge.Provider.TOTP == "" {
return http.Cookie{}, fmt.Errorf("Server Provided no TOTP Provider") return http.Cookie{}, fmt.Errorf("Server Provided no TOTP Provider")
} }
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
@ -100,14 +100,14 @@ func GetClient(ctx context.Context) (*api.Client, error) {
return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err) return http.Cookie{}, fmt.Errorf("Reading TOTP: %w", err)
} }
fmt.Printf("\n") fmt.Printf("\n")
req := api.MFAChallangeResponse{ req := api.MFAChallengeResponse{
TOTP: code, TOTP: code,
} }
var raw *http.Response var raw *http.Response
raw, _, err = c.DoCustomRequestAndReturnRawResponse(ctx, "POST", "mfa/verify/totp.json", "v2", req, nil) raw, _, err = c.DoCustomRequestAndReturnRawResponse(ctx, "POST", "mfa/verify/totp.json", "v2", req, nil)
if err != nil { if err != nil {
if errors.Unwrap(err) != api.ErrAPIResponseErrorStatusCode { if errors.Unwrap(err) != api.ErrAPIResponseErrorStatusCode {
return http.Cookie{}, fmt.Errorf("Doing MFA Challange Response: %w", err) return http.Cookie{}, fmt.Errorf("Doing MFA Challenge Response: %w", err)
} }
fmt.Println("TOTP Verification Failed") fmt.Println("TOTP Verification Failed")
} else { } else {
@ -120,7 +120,7 @@ func GetClient(ctx context.Context) (*api.Client, error) {
return http.Cookie{}, fmt.Errorf("Unable to find Passbolt MFA Cookie") return http.Cookie{}, fmt.Errorf("Unable to find Passbolt MFA Cookie")
} }
} }
return http.Cookie{}, fmt.Errorf("Failed MFA Challange 3 times: %w", err) return http.Cookie{}, fmt.Errorf("Failed MFA Challenge 3 times: %w", err)
} }
case "noninteractive-totp": case "noninteractive-totp":
helper.AddMFACallbackTOTP(client, viper.GetUint("mfaRetrys"), viper.GetDuration("mfaDelay"), viper.GetDuration("totpOffset"), viper.GetString("totpToken")) helper.AddMFACallbackTOTP(client, viper.GetUint("mfaRetrys"), viper.GetDuration("mfaDelay"), viper.GetDuration("totpOffset"), viper.GetString("totpToken"))