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

Authenticating with a token and user/pass in NATS JetStream resources #3010

Open
ghstahl opened this issue Nov 15, 2024 · 1 comment
Open
Labels
effort: lower A lower effort issue that should be possible to complete (relatively) quickly enhancement nats Issues relating to NATS and Jetstream

Comments

@ghstahl
Copy link

ghstahl commented Nov 15, 2024

should be part of this old one

Nats connecting by token

// Set a token
nc, err := nats.Connect("127.0.0.1", nats.Name("API Token Example"), nats.Token("mytoken"))
if err != nil {
    log.Fatal(err)
}
defer nc.Close()

// Do something with the connection

Current

 auth:
      nkey_file: ./seed.nk # No default (optional)
      nkey: "" # No default (optional)
      user_credentials_file: ./user.creds # No default (optional)
      user_jwt: "" # No default (optional)
      user_nkey_seed: "" # No default (optional)

I am currently using a token to connect which is handled by our AuthCallout.

@ghstahl ghstahl changed the title Authenticating with a token in NATS JetStream resources Authenticating with a token and user/pass in NATS JetStream resources Nov 15, 2024
@mihaitodor mihaitodor added enhancement nats Issues relating to NATS and Jetstream effort: lower A lower effort issue that should be possible to complete (relatively) quickly labels Nov 15, 2024
ghstahl added a commit to ghstahl/repanda-data-connect that referenced this issue Nov 15, 2024
@ghstahl
Copy link
Author

ghstahl commented Jan 11, 2025

When using auth callout in nats I am able to pass my token as the password in the username/password option.

usernameHanlder := nats.UserInfo("mapped", token)

nc, err := nats.Connect(request.NATSUrl, usernameHanlder)

Its a hack, but I have seen microsoft azure do the same thing where they do some basic auth where the user is some static thing, and the password is the encoded token.

I am trying to get it to work where I pass a userJWT where it really isn't a jwt but mytoken. I think nats intercepts this and doesn't pass it to the callout. If this works then I can use existing benthos and just overload user_jwt: "" # No default (optional)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: lower A lower effort issue that should be possible to complete (relatively) quickly enhancement nats Issues relating to NATS and Jetstream
Projects
None yet
Development

No branches or pull requests

2 participants