nexus
nexus copied to clipboard
Add CryptoSignAuth Example.
I'm having issue while implementing CryptoSignAuth, Please add an example to easily understand.
We now have Cryptosign auth working with Nexus client. See this code for example https://github.com/codebasepk/wick/blob/6f390db0745744eb66ab190db6fce67bbe9cdab5/wamp/main.go#L131
@asimfarooq5 I am guessing that your problem is the same as described in #252. If so, an example would not help in this case because it was not a misuse. This was due to an issue within the crauth package when using derived keys.
Currently, the only example is here.
I believe this issue is about CryptoSign and not WAMP-CRA. We didn't find any examples about cryptosign when we were looking. However we did figure that out eventually by looking at the source code. https://github.com/codebasepk/wick/blob/15d2e5c5ddeb048ea0cf32eaff4f5f3545e0f5d6/wamp/main.go#L169
work example pvk - is private key with ed25519
cfg := client.Config{
Realm: "SOMEREALM",
Serialization: client.CBOR,
ResponseTimeout: time.Duration(10 * time.Second),
HelloDetails: wamp.Dict{
"authid": "MYAUTHID",
},
AuthHandlers: map[string]client.AuthFunc{
"cryptosign": func(c *wamp.Challenge) (string, wamp.Dict) {
bchallenge, err := hex.DecodeString(c.Extra["challenge"].(string))
if err != nil {
return "", wamp.Dict{}
}
return fmt.Sprintf("%s%s", hex.EncodeToString(ed25519.Sign(PKey, bchallenge)), c.Extra["challenge"].(string)), wamp.Dict{}
},
},
}
conn, err := client.ConnectNet(ctx, "wss://.....", cfg)
@gendalf Thanks for the example! Can you create a PR with a docs update? Or even better: a working example in the examples directory? So anyone can find it there instead of digging through the github...