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

Allow tokens in connection strings and add tests #506

Merged
merged 2 commits into from
Jun 16, 2022
Merged

Allow tokens in connection strings and add tests #506

merged 2 commits into from
Jun 16, 2022

Conversation

paulgb
Copy link
Contributor

@paulgb paulgb commented Jun 15, 2022

Many NATS clients allow for token authentication to be specified in a connection URL by passing a username without a password. This enables that approach, and adds some tests.

If this looks good, I'm happy to make a similar change on the async_nats side, either in this PR or in a follow-up as appropriate.

@caspervonb caspervonb requested review from Jarema and caspervonb June 16, 2022 01:17
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

Hello there! thanks for the PR! with tests too, I like that 😁
Additions look good, some clippy and rustfmt errors.

One thing tho, even if we're pre 1.0 we try to minimize breaking changes and keep the nats crate stable. So we'd probably want to preserve has_user_pass and introduce something like has_token?

CC @Jarema

@@ -603,9 +604,18 @@ impl ServerAddress {
self.0.scheme() == "tls"
}

/// Returns if the server url had embedded username and password.
pub fn has_user_pass(&self) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Public method, so probably don't want to be removing that outright.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I didn't mean to remove that. I've added it back.

@Jarema
Copy link
Member

Jarema commented Jun 16, 2022

@paulgb thanks for that PR!

Now it IMHO looks good!

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for your contribution!

Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

lgtm, thank you 💯

@Jarema Jarema merged commit c9cd352 into nats-io:main Jun 16, 2022
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