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 A Novice One-Liner For Ease Of Use! #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vthg2themax
Copy link

Add A Novice One-Liner For Ease Of Use so that someone just jumping in would be able to run this when they grab the crate down.

Add A Novice One-Liner For Ease Of Use so that someone just jumping in would be able to run this when they grab the crate down.
@steffengy
Copy link
Owner

The implementation you copied from the example is not exactly production ready.
It has print statements, a configuration that is not as secure as possible, missing error handling, ...
So it serves as short example that shows how to use it in principle but nothing that I would be comfortable having as default in winauth itself as-is.

Add an easy to use One-Liner for a Novice User to get started with this crate.
@vthg2themax
Copy link
Author

Thank you very much for your constructive feedback! I have attempted to address the deficiencies in the code submitted. Please let me know if it's still not good, and if so, what I may do to improve it further please. Thanks again!

@steffengy
Copy link
Owner

steffengy commented Oct 4, 2019

It might make sense to rewrite the macro as function to address the following shortcomings.
There really isn't a reason this is a macro, besides it was quicker writable for demo purposes.

The most important shortcomings:

  1. The error handling should not panic, but expose an Result that the user can handle and decide what to do with the error.
  2. The NtlmSspiBuilder cannot be customized.
    It also doesn't take multi-platform support into account, the macro e.g. only works on windows.
  3. For versioning a dependency of winauth to reqwest has the downside of preventing us to upgrade to a newer reqwest version without bumping the version of winauth itself.
    I'm myself not sure what the best approach here is, maybe a winauth-reqwest crate.
    We could also just decide to not care and include reqwest support in winauth as a easy starter, but we cannot do so for more implementations (hyper, ...) as it eventually becomes chaotic version-wise.

@vthg2themax
Copy link
Author

I think keeping it as a macro would be the best option for that very reason. If it were to become a function, then the project would depend on reqwest, even if another library becomes a better option. Could changing the Macro's name be a better solution instead, since at that point it would be assumed that it is a simple reqwest being made? I can definitely take care of points 1, and 2. Thanks again for your excellent code critiques!

@steffengy
Copy link
Owner

It depends on reqwest in any case.
With a macro, the dependency is implicit - which actually is worse, since the user has to ensure his Cargo.toml has a dependency (of the right version) to reqwest.
So with a macro we're actually unable to update the underlying reqwest version or use another library, since that would be a backwards-compatibility breaking change.
Exposing a "blackbox" function hiding reqwest on the other hand does not have this downside.

@vthg2themax
Copy link
Author

vthg2themax commented Oct 15, 2019 via email

@steffengy
Copy link
Owner

No, since reqwest is not used in winauth but only examples, winauth doesn't have any dependency to reqwest. My point is that if we expose a simple function that allows doing http requests for convenience it should be with an an explicit dependency, so we can atleast somewhat guarantee backwards compatibility.

@vthg2themax
Copy link
Author

vthg2themax commented Oct 15, 2019 via email

@steffengy
Copy link
Owner

In priciple having a convenience interface that just allows users to do authenticated NTLM requests is something I'm fine with. Getting the API right is another story though ;)

A single function probably won't do, since you'll need to specify http method, headers, etc. - probably something like a wrapper around reqwest::RequestBuilder, but we can use types from the http crate in theory.
(To decouple our public API from reqwest, so if reqwest updates a version we can update the version of reqwest we use, without breaking backwards compatibility).
==> This is much more work than it looks like

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.

2 participants