nexus icon indicating copy to clipboard operation
nexus copied to clipboard

Add CryptoSignAuth Example.

Open asimfarooq5 opened this issue 3 years ago • 5 comments

I'm having issue while implementing CryptoSignAuth, Please add an example to easily understand.

asimfarooq5 avatar Oct 05 '21 15:10 asimfarooq5

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

om26er avatar Oct 24 '21 17:10 om26er

@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.

gammazero avatar Jan 15 '22 06:01 gammazero

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

om26er avatar Jan 15 '22 20:01 om26er

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 avatar Oct 16 '22 11:10 gendalf

@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...

KSDaemon avatar Oct 17 '22 14:10 KSDaemon