mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-10 01:48:22 +00:00
add mfa Cookie to storage
This commit is contained in:
parent
7fdad5269b
commit
151bd9643b
1 changed files with 8 additions and 2 deletions
|
@ -22,6 +22,7 @@ type Client struct {
|
||||||
|
|
||||||
sessionToken http.Cookie
|
sessionToken http.Cookie
|
||||||
csrfToken http.Cookie
|
csrfToken http.Cookie
|
||||||
|
mfaToken http.Cookie
|
||||||
|
|
||||||
// for some reason []byte is used for Passwords in gopenpgp instead of string like they do for keys...
|
// for some reason []byte is used for Passwords in gopenpgp instead of string like they do for keys...
|
||||||
userPassword []byte
|
userPassword []byte
|
||||||
|
@ -29,8 +30,10 @@ type Client struct {
|
||||||
userPublicKey string
|
userPublicKey string
|
||||||
userID string
|
userID string
|
||||||
|
|
||||||
// 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.
|
// used for solving MFA challanges. You can block this to for example wait for user input.
|
||||||
MFACallback func(ctx context.Context, c *Client, res *APIResponse) error
|
// You shouden't run any unrelated API Calls while you are in this callback.
|
||||||
|
// You need to Return the Cookie that Passbolt expects to verify you MFA, usually it is called passbolt_mfa
|
||||||
|
MFACallback func(ctx context.Context, c *Client, res *APIResponse) (http.Cookie, error)
|
||||||
|
|
||||||
// Enable Debug Logging
|
// Enable Debug Logging
|
||||||
Debug bool
|
Debug bool
|
||||||
|
@ -111,6 +114,9 @@ func (c *Client) newRequest(method, path string, body interface{}) (*http.Reques
|
||||||
req.Header.Set("X-CSRF-Token", c.csrfToken.Value)
|
req.Header.Set("X-CSRF-Token", c.csrfToken.Value)
|
||||||
req.AddCookie(&c.sessionToken)
|
req.AddCookie(&c.sessionToken)
|
||||||
req.AddCookie(&c.csrfToken)
|
req.AddCookie(&c.csrfToken)
|
||||||
|
if c.mfaToken.Name != "" {
|
||||||
|
req.AddCookie(&c.mfaToken)
|
||||||
|
}
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
c.log("Request URL: %v", req.URL.String())
|
c.log("Request URL: %v", req.URL.String())
|
||||||
|
|
Loading…
Add table
Reference in a new issue