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

POC for Kerberos on Windows with SSPI #20

Closed
wants to merge 32 commits into from
Closed

POC for Kerberos on Windows with SSPI #20

wants to merge 32 commits into from

Conversation

vkarpov15
Copy link
Contributor

I added 5 new files:

  • kerberos_sspi.*: these are thin wrappers around windows system calls that help with loading DLLs, they're copied exactly from the node driver's SSPI implementation
  • sasl_sspi.c, sasl_sspi.h: some glue to make it easier to use the windows system calls from Go. Mostly, its just a C adaptation of Eric Milkie's implementation for the mongo shell
  • sasl_sspi.go: exposes the same API as sasl.go but uses Windows SSPI instead of SASL.

Still a couple outstanding issues, most notably that 1) I haven't added tests yet (see #12, among other limitations which we can discuss), and 2) only ANSI support for now, no unicode, because for some reason my testing setup is blowing up when I try to use unicode.

}

// Make sure we've cleaned up all the buffers we malloced when we're sure we don't need em anymore
if ss.authComplete || ss.errored {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is being closed, why would buffers not be freed? Close should mean "stop doing everything you are doing and free all resources".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got some weird errors because Close gets called after every step. Figured this would be a reasonable way to not dive down the windows rabbit hole while avoiding leaking memory.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I understand the issue. Close cannot be called after a step unless the saslSession is not going to be touched anymore, and if that's the case its resources should be released or we do have leaks. If there are lurking errors, we should understand them as there's likely a fundamental issue in the way we're using the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok done


// Call the function
return (*pfn_queryContextAttributes)(
phContext, ulAttribute, pBuffer
Copy link
Contributor

Choose a reason for hiding this comment

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

We can have it all in a single line.

@niemeyer
Copy link
Contributor

niemeyer commented Sep 4, 2014

Thanks for the work, Valeri. A few initial comments above.

@niemeyer niemeyer closed this Sep 4, 2014
@niemeyer niemeyer reopened this Sep 4, 2014
@niemeyer
Copy link
Contributor

niemeyer commented Sep 4, 2014

Sorry, wrong button.. didn't mean to close it.

@vkarpov15
Copy link
Contributor Author

In general, I'd rather not make too many changes to kerberos_sspi.*, because those are copied directly from Christian's code, and I'd like to be able to import future bug fixes without too much work. I'd appreciate it if you have a better way of pulling in that code though, I agree the style of kerberos_sspi.* doesn't match the rest of the code and that's unpleasant.

@niemeyer
Copy link
Contributor

niemeyer commented Sep 4, 2014

I'm all for having less code that we need to maintain, but the proper way to do that is to use an external library, which is the process I have followed to implement the current support in Linux, and which hopefully actually works in Windows too (I never got a proper response to whether it does work there or not, and why not, given that the library does mention support for Windows). I'd be quite surprised if there's no proper library that abstract that exact API for multiple operating systems.

That said, if you prefer implementing it that way, and supporting it too, that's okay too. But if we are going down the rabbit role of importing external code, we'll need to maintain that code sane and working for us. That includes file headers, fixing things such as the loose error handling, adding tests, and on the bright side getting rid of code that we're in fact not depending upon. Looks like we can get rid of quite a bit of it.

@vkarpov15
Copy link
Contributor Author

I don't know the exact reasoning why Cyrus SASL doesn't work for Kerberos on Windows. Probably due to the fact that Windows-flavored Kerberos enables you to get a TGT ticket in the process itself without going through kinit. As far as I can tell, that's the most obvious difference between these two APIs. Regardless, using SSPI's API on Windows is the established standard for mongodb clients, both the shell and the handful of drivers that implement this use it.

Given the sorry state of go's package management, I think its a better idea to keep the code in there. I'll go in and make kerberos_sspi conform to some reasonable stylistic standards.

@niemeyer
Copy link
Contributor

niemeyer commented Sep 5, 2014

Having experience with other lands, I don't find Go's package management to be in a sorry state, but let's have that conversation in a different forum.

I'm happy to support you in merging this work nevertheless. Let's just try to polish it to a state where we're both happy to maintain it in-tree.

@vkarpov15
Copy link
Contributor Author

Thanks. Let me know if you have any more comments on the most recent iteration, I did what I could to clean up the kerberos_sspi files.

This cuts down the timing further to 22.5ns/op,
or 1/300th of the original.
@niemeyer
Copy link
Contributor

Going over the comments above, I still see a number of uncovered points.

One easy way to ensure we're on the same page is by responding to the actual comments, even if it's just a "Done." This gives a chance for both of us to tell whether things were completed, or whether there was a disagreement, and what was it.

@niemeyer
Copy link
Contributor

Also, can we please drop the "_" prefix from all of the C function names? These are just normal functions in our own namespace.

niemeyer and others added 3 commits September 11, 2014 17:54
This prevents blocks of 512k from being allocated to hold
the 256k data field plus metadata.

Fixes MGO-28.
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.

4 participants