When I directly call the Casdoor API, everything works perfectly.
(Here, the SECRET and RECOVERY_CODES are obtained from the /api/mfa/setup/initiate endpoint.)
curl --location --request POST 'http://localhost:8000/api/mfa/setup/enable?mfaType=app&owner=appscode&secret=SECRET&dest=null&recoveryCodes=RECOVERY_CODES&name=NAME' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {{token}}' \
--header 'Cookie: casdoor_session_id=SESSION_ID'
However, I’m encountering an issue when trying to perform the same action using the Go SDK.
Problem Details
In the Go SDK code, the Enable function does not accept recoveryCodes as a parameter.
As a result, when I invoke it, I receive the following response:
Response:
{
"error": "Failed to enable MFA: recovery codes is missing"
}
SDK Code Snippet
func (c *Client) Enable(owner, mfaType, name, secret string) (*MfaVerifyResponse, error) {
mfaReq := MfaRequest{
Owner: owner,
MfaType: mfaType,
Name: name,
Secret: secret,
}
postBytes, err := json.Marshal(mfaReq)
if err != nil {
return nil, err
}
resp, err := c.DoPost("mfa/setup/enable", nil, postBytes, true, false)
if err != nil {
return nil, err
}
dataBytes, err := json.Marshal(resp.Data)
if err != nil {
return nil, err
}
var mfaResp MfaVerifyResponse
err = json.Unmarshal(dataBytes, &mfaResp)
if err != nil {
return nil, err
}
return &mfaResp, nil
}
Am I missing something. TA
I'm facing an issue with casdoor-go-sdk while trying to disable MFA.
curl --location --request DELETE 'http://localhost:8080/mfa/delete' \
--header 'accept: application/json' \
--header 'Authorization: Bearer TOKEN' \
--header 'Cookie: casdoor_session_id=33d52c14da83ef185e48a348a61df131'
Response
{
"error": "Failed to delete MFA: unexpected end of JSON input"
}
Code snippet to call delete
// Call Casdoor SDK's Delete method
// This hits: POST /api/delete-mfa
err := casdoorClient.Delete(
user.User.Owner,
user.User.Name,
)
Am I missing something here?
Thanks in advance.
I'm facing an issue with casdoor-go-sdk while trying to enable MFA.
When I directly call the Casdoor API, everything works perfectly.
(Here, the SECRET and RECOVERY_CODES are obtained from the /api/mfa/setup/initiate endpoint.)
curl --location --request POST 'http://localhost:8000/api/mfa/setup/enable?mfaType=app&owner=appscode&secret=SECRET&dest=null&recoveryCodes=RECOVERY_CODES&name=NAME' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {{token}}' \
--header 'Cookie: casdoor_session_id=SESSION_ID'
However, I’m encountering an issue when trying to perform the same action using the Go SDK.
Problem Details
In the Go SDK code, the Enable function does not accept recoveryCodes as a parameter.
As a result, when I invoke it, I receive the following response:
Response:
{
"error": "Failed to enable MFA: recovery codes is missing"
}
SDK Code Snippet
func (c *Client) Enable(owner, mfaType, name, secret string) (*MfaVerifyResponse, error)
Am I missing something here?
Should the SDK include recoveryCodes as part of the request payload, or is there another recommended way to handle this?
Thanks in advance for your help!
