Skip to content
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

Add CryptoSignAuth Example. #251

Open
asimfarooq5 opened this issue Oct 5, 2021 · 5 comments
Open

Add CryptoSignAuth Example. #251

asimfarooq5 opened this issue Oct 5, 2021 · 5 comments

Comments

@asimfarooq5
Copy link

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

@om26er
Copy link
Contributor

om26er commented Oct 24, 2021

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

@gammazero
Copy link
Owner

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

@om26er
Copy link
Contributor

om26er commented Jan 15, 2022

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

@gendalf
Copy link

gendalf commented Oct 16, 2022

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)

@KSDaemon
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants