-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexpected value for field Ipatokenotpkey returned by OtptokenAdd #9
Comments
Can you provide a minimal code sample to reproduce the error ?
I don't think so. I think that this is due to a bad data type in the generated code.
|
This is exactly the code that I'm using (with password redacted) package main
import (
"crypto/rand"
"crypto/tls"
"encoding/base32"
"encoding/base64"
"encoding/hex"
"log"
"net/http"
"github.com/ccin2p3/go-freeipa/freeipa"
"github.com/google/uuid"
)
func main() {
tspt := &http.Transport{
TLSClientConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
},
}
c, err := freeipa.Connect("HOST", tspt, "admin", "PASSWORD")
if err != nil {
log.Fatal(err)
}
tokenuuid := uuid.NewString()
tokenbytes := make([]byte, 32)
rand.Read(tokenbytes)
log.Printf("Token UUID: %s", tokenuuid)
log.Printf("Token base32: %s", base32.StdEncoding.EncodeToString(tokenbytes))
log.Printf("Token base64: %s", base64.StdEncoding.EncodeToString(tokenbytes))
log.Printf("Token hex: %s", hex.EncodeToString(tokenbytes))
addres, err := c.OtptokenAdd(tokenuuid, &freeipa.OtptokenAddArgs{}, &freeipa.OtptokenAddOptionalArgs{
Type: freeipa.String("totp"),
Ipatokenowner: freeipa.String("test"),
Ipatokenotpkey: freeipa.String(base32.StdEncoding.EncodeToString(tokenbytes)),
Ipatokenotpalgorithm: freeipa.String("sha1"),
Ipatokenotpdigits: freeipa.Int(6),
All: freeipa.Bool(true),
NoQrcode: freeipa.Bool(true),
})
if err != nil {
log.Fatal(err)
}
log.Printf("Response: %+v", addres)
} If I remove error checking at the end, the response is Thank you for your time |
Hi,
ipa --version
returns:VERSION: 4.10.0, API_VERSION: 2.249
Using
OtptokenAdd
returns the following error:The response is
<nil>
. However, the token is created in freeipa successfully, so I assume that this is problem with parsing of response.Could generating the library again help? And which version of freeipa is this library currently based on?
Thanks
The text was updated successfully, but these errors were encountered: