From f01926b1c5ba9189e7ee0ce0a78e512547567d33 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Mon, 20 Sep 2021 10:23:59 +0200 Subject: [PATCH] add MFA structs, Make Callback Public --- api/api.go | 4 ++-- api/client.go | 3 ++- api/mfa.go | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 api/mfa.go diff --git a/api/api.go b/api/api.go index ff57891..75835b2 100644 --- a/api/api.go +++ b/api/api.go @@ -58,8 +58,8 @@ start: // if we are here this probably means that the MFA callback is broken, to prevent a infinit loop lets error here return r, &res, fmt.Errorf("Got MFA challenge twice in a row, is your MFA Callback broken? Bailing to prevent loop...:") } - if c.mfaCallback != nil { - err = c.mfaCallback(c, &res) + if c.MFACallback != nil { + err = c.MFACallback(ctx, c, &res) if err != nil { return r, &res, fmt.Errorf("MFA Callback: %w", err) } diff --git a/api/client.go b/api/client.go index 26bd2d7..161446e 100644 --- a/api/client.go +++ b/api/client.go @@ -29,7 +29,8 @@ type Client struct { userPublicKey string userID string - mfaCallback func(c *Client, res *APIResponse) error + // used for solving MFA challanges. You can block this to for example wait for user input. You shouden't run any unrelated API Calls while you are in this callback. + MFACallback func(ctx context.Context, c *Client, res *APIResponse) error // Enable Debug Logging Debug bool diff --git a/api/mfa.go b/api/mfa.go new file mode 100644 index 0000000..113e3d3 --- /dev/null +++ b/api/mfa.go @@ -0,0 +1,13 @@ +package api + +type MFAChallange struct { + Provider MFAProviders `json:"providers,omitempty"` +} + +type MFAProviders struct { + TOTP string `json:"totp,omitempty"` +} + +type MFAChallangeResponse struct { + TOTP string `json:"totp,omitempty"` +}