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

chore: fix, provider initiates lattice nats connection with seed and … #179

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Solverj
Copy link

@Solverj Solverj commented Jan 23, 2025

Provider now initiates nats lattice connection in-case host provides jwt and seed, if not default to only connecting using nats-url.

Feature or Problem

Provider fails with: Failed to connect to NATS: authorization violation: nats: authorization violation
when using provider and lattice requires credentials authentication

Related Issues

Resolves:
#176

Release Information

next release

Consumer Impact

Shouldn't be any blast radius as you're not allowed to start a wasmcloud host without a nats connection.

Testing

Testing it right now, will update from draft when done. Tried it only through vendor editing.

Unit Test(s)

N/A

Acceptance or Integration

N/A

Manual Verification

Attached a custom provider to a component which before the change, had no nats credentials towards the lattice which failed.
Tried with this change, and it now works as expected.

…jwt provided by host in-case lattice requires it, if not then default to using only nats-url.
@Solverj Solverj requested a review from a team as a code owner January 23, 2025 12:40
@Solverj Solverj marked this pull request as draft January 23, 2025 13:06
@brooksmtownsend
Copy link
Member

Looks good to me @Solverj, looks like you'll just need to sign off your commits (see details in https://github.com/wasmCloud/go/pull/179/checks?check_run_id=36058847245) and mark this as "ready for review" and we can get this merged

Comment on lines +156 to +164
var nc *nats.Conn
if hostData.LatticeRPCUserSeed != "" && hostData.LatticeRPCUserJWT != "" {
opts := nats.UserJWTAndSeed(hostData.LatticeRPCUserJWT, hostData.LatticeRPCUserSeed)
logger.Debug("connecting to nats with userJWTAndSeed")
nc, err = nats.Connect(hostData.LatticeRPCURL, opts)
} else {
logger.Debug("connecting to nats", "url", hostData.LatticeRPCURL)
nc, err = nats.Connect(hostData.LatticeRPCURL)
}
Copy link
Member

@joonas joonas Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be preferable to connect once, optionally providing connection options if the appropriate configuration is available, something like:

	var ncopts []nats.Option
	if hostData.LatticeRPCUserSeed != "" && hostData.LatticeRPCUserJWT != "" {
		logger.Debug("Using UserJWT and Seed for connection")
		ncopts = append(ncopts, nats.UserJWTAndSeed(hostData.LatticeRPCUserJWT, hostData.LatticeRPCUserSeed))
	}
	nc, err = nats.Connect(hostData.LatticeRPCURL, ncopts)

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

Successfully merging this pull request may close these issues.

3 participants