-
Notifications
You must be signed in to change notification settings - Fork 152
Negotiate #537
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
base: main
Are you sure you want to change the base?
Negotiate #537
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - so we are adding a bool config field to the http client to enable a few more auth/protocols - this is great, I think that this is an improvement no doubt.
A few things:
Couldn't we simplify spnego_kerberos.go significantly?
For instance we are loading the krb5.conf - we have some fallback mechanisms if the env var KRB5_CONFIG hasn't been supplied, and using file, err := os.Open and config.NewFromReader(file) - Couldn't we just create a Bento config field, say krb5_config_filepath and then use config.Load(filepath)?
As well here, you then have a large implementation of RoundTrip - A lot of this seems that it would be better if it was provided by the dependency - but that only provides a Client and not a Transport ...
Documentation / New Config fields
Most user configuration is supplied to Bento via the config fields - rather than make use of Env Vars being set - we should be using config fields. When config fields are used and are given adequate documentation it helps to keep Bento maintainable and usable.
I think that we should look at including something more descriptive - a config object field rather than a single bool?
Kind of going back to the point around loading the config - currently with the fallback - there is no documentation to say, set this Env Var, and we will also fallback to xyz on windows, mac etc. Let's keep it simple and expose a config field to set for the krb5.conf (we could allow both a string in the yaml config or a filepath, similar to tls) but if either of those fail then we report error back to the user.
spnego_windows.go
Admittedly I haven't looked at this one much - but why do we need a separate impl for windows? Can't jcmturner/gokrb5 do what we need it to do? It does mention Active Directory here - and also it's written in pure go?
Tests
We could do with some tests I think - I have been taking a look at this spnego and kerberos and have a working docker setup - would you be able to include an integration test using the docker image: gcavalcante8808/krb5-server ? If not it's no big deal - I will look to add one but want to address the above first I think?
|
Thanks for the review. I only published the implementation in this form after careful consideration.
The reason I decided against a configuration field is more or less to stick to the standard implementation of all applications.
Exactly. There is no RoundTrip dependency here. There was an issue about this at one point, but it was closed and they just said that you have to implement it yourself.
Here I must say that I have adhered to the standard of most client solutions. The most notable example here would be ‘curl’.
So I just have to say: Please don't.
Of course we can do that. However, I believe that we can only add Keberos to the automatic tests here. It should be noted that I already have the Windows site up and running productively and have not encountered any problems so far. |
...
OK - I can see that But on the man page for curl - it does go into then detail regarding: "This option requires a library built with GSS-API or SSPI support. Use Which I can see that when I do With this PR don't we need to document that Bento supports Kerberos / sspi / ntlm? This just currently isn't mentioned is it. Wouldn't altering PR's Isn't this how it works 'negotiate' is SPNEGO and that then will select the actual authentication protocol - Kerberos / ntlm / sspi ... ? Seems like we need to make this an object field, so that we can extend it in the future with more auth protocols & provide documentation for each of the auth protocols bento can be configured with? With sspi - there is no config to supply there - how about a Bento config option
My questions here regarding spnego_windows.go - why do we need both, is it because you originally developed with windows in mind for your own use-case and then used the other library to implement for unix system?
Ok sounds good, I can convert my set-up for a kerberos int. test then and perhaps we can leave windows as-is. I think there wasn't much info for the issue & PR, all we had was: PR Title: Negotiate Desc: fixes #378 In the issue we have a link to https://github.com/alexbrainman/sspi/blob/master/negotiate/http_test.go And then coupled with the lack of documentation & tests in the PR itself has meant more reading for me. (But probably would have to do it anyway...) |
Okay thats a good idea. Another idea is to support also gssapi (i need to figure out how to use it): https://github.com/jcmturner/gokrb5/tree/master/gssapi And for ntlm: https://github.com/Azure/go-ntlmssp
Yes, I initially incorporated sspi here primarily out of my own internal interest. For the sake of completeness and, of course, to improve bento here, I subsequently implemented the Linux page as well.
Yes, at the time I created this issue, I really didn't have any experience. I had only used sspi at different levels. |
|
@jem-davies I think that's the last message for now. If you give me the go-ahead, I'll start working on the changes. |
Ok great thanks again! Yeah I think my main concern was that the auth mechanism options weren't documented - so those changes you propose will rectify that. I think that even if we just had a list of strings (string enum field) for negotiate:
- kerberos
- ... Then for each of the elements some documentation that explains how to set that up (i.e. with kerberos which env var to set). After you explained about We can tackle the other gssapi etc. in some follow-up prs - just add the option to the enum? |
|
@jem-davies i know i know ... its another message (the last message was not the last message 😅 ) okay im fine with this! First i will documentate it. So we can to new stuff later. Currently i need to think about the enable/disable mechanism.
So spnego is a protocol which wraps keberos or ntlm (or other procols from sspi/gssapi). I implemented spnego myself for sspi and use spnego from the keberos lib. I have to admit, this topic is giving me a bit of a headache. So correct would be (which has some issues just to have better documentations?): Support only keberos and ntlm for now?
I could also strip ntlm for now. I mean ... its a deprecated protocol. An alternative approach is: just use negotiation and let spnego decide. (This is my current approach) But you say: it should be a string enum to be documented. Which then can be cofigurated and has per auth documentation. |
|
So to round up: So spnego fallback is ntlm. Option 1: just keep the current solution and improve the documentation
Option 2: strip out the ntlm implementation for now and use a standalone spnego implementation
Option 3: keep ntlm with the documentation: only works with sspi for now
|
|
Lets go with this rfc: https://datatracker.ietf.org/doc/html/rfc4559 I will also now include ntlm to be complete
And this configuration: |


fixes: #378