-
Notifications
You must be signed in to change notification settings - Fork 30
Negotiate improvements #4
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
Negotiate improvements #4
Conversation
|
Note: I had to change the prototype from sspi.AcquireCredentials in order to pass the principal name since the C++ code I was porting made use of this parameter. Not breaking the current signature would require a new function (sspi.AcquireCredentialsForPrincipal ?), please let me know if you feel this is a better option. |
|
I will try to review this weekend. Alex |
alexbrainman
left a comment
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.
Most of it looks fine to me.
Thank you.
Alex
| return makeSignature(c.sctxt, msg, qop, seqno) | ||
| } | ||
|
|
||
| // EncryptMessage uses the established client context to encrypt a message |
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.
Can you, please, add a test for EncryptMessage and DecryptMessage ?
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.
Done
| // AcquireUserCredentials and SPN to start client Negotiate | ||
| // AcquireUserCredentials and SPN to start a client Negotiate | ||
| // negotiation sequence. targetName is the service principal name | ||
| // (SPN) or the security context of the destination server. |
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.
You do not mention new "flags" parameter in the documentation. Don't you want to say something about it?
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.
You did not address my comment.
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.
The flags parameter is documented in AcquireUserCredentialsWithFlags, did you mean something else ?
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.
My fault, I have no idea why I asked you to document "flag" parameter here. Forget my comment.
| } | ||
|
|
||
| func AcquireCredentials(pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { | ||
| func AcquireCredentials(principal string, pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { |
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.
This commit changes the way "principal" parameter of "" is handled. What is happening here is not obvious. This needs to be at least documented in function doco.
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.
An empty principal parameter is passed as a nil pointer in the underlying winapi call. I will document.
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.
I still do not see any new documentation that you promised.
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.
I forgot this part, sorry. I'll fix that.
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.
Please, do.
negotiate/negotiate.go
Outdated
| } | ||
|
|
||
| // AcquireServerCredentials acquires server credentials that will | ||
| // be used to authenticate client. |
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.
Maybe add new "principalName" parameter documentation.
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.
You did not address my comment.
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.
I'm sorry, I'm afraid I did not understand what you meant here... Do you suggest to add a new parameter "principalName" to AcquireUserCredentials ?
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.
You have added "principalName" parameter to AcquireServerCredentials function. You should document new parameter - explain what it does.
| if ret != sspi.SEC_E_OK { | ||
| return "", ret | ||
| } | ||
| defer sspi.FreeContextBuffer((*byte)(unsafe.Pointer(ns.ClientName))) |
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.
Why aren't you freeing ServerName too?
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.
It was simply an oversight, fixed !
48f578e to
816b5ac
Compare
|
Hi, I made the requested changes and updated my branch, PTAL |
alexbrainman
left a comment
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.
I still see some of my comments not addressed. Please, let me know, if I am missing something.
Alex
negotiate/negotiate.go
Outdated
| } | ||
|
|
||
| // AcquireServerCredentials acquires server credentials that will | ||
| // be used to authenticate client. |
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.
You did not address my comment.
| } | ||
|
|
||
| func AcquireCredentials(pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { | ||
| func AcquireCredentials(principal string, pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { |
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.
I still do not see any new documentation that you promised.
| // AcquireUserCredentials and SPN to start client Negotiate | ||
| // AcquireUserCredentials and SPN to start a client Negotiate | ||
| // negotiation sequence. targetName is the service principal name | ||
| // (SPN) or the security context of the destination server. |
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.
You did not address my comment.
alexbrainman
left a comment
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.
I hope that I explained myself better this time.
And, please, rebase your changes, because I just pushed new change into this repo.
Thank you.
Alex
| // AcquireUserCredentials and SPN to start client Negotiate | ||
| // AcquireUserCredentials and SPN to start a client Negotiate | ||
| // negotiation sequence. targetName is the service principal name | ||
| // (SPN) or the security context of the destination server. |
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.
My fault, I have no idea why I asked you to document "flag" parameter here. Forget my comment.
negotiate/negotiate.go
Outdated
| } | ||
|
|
||
| // AcquireServerCredentials acquires server credentials that will | ||
| // be used to authenticate client. |
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.
You have added "principalName" parameter to AcquireServerCredentials function. You should document new parameter - explain what it does.
| } | ||
|
|
||
| func AcquireCredentials(pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { | ||
| func AcquireCredentials(principal string, pkgname string, creduse uint32, authdata *byte) (*Credentials, error) { |
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.
Please, do.
This allows to pass specific useful flags (like sspi.ISC_REQ_INTEGRITY or ISC_REQ_INTEGRITY)
Setting this parameter to an empty string will pass nil to the underlying windows sspi function. Only the negotiate public api is changed in this commit (since the C++ code I'm porting was explicitely using this parameter).
This method returns the username corresponding to the authenticated client
Explicitely returning the serverDone boolean allows for slightly cleaner code
816b5ac to
55a2fc7
Compare
|
Branch updated and rebased, please let me know if I still missed anything, thanks ! |
|
LGTM now. Thank you. Alex |
|
Merged, so closing this now. Alex |
Hi,
This branch contains various changes / improvements to the negotiate package (FYI those changes were added in order to implement both Web SPNEGO and SASL GSS-SPNEGO support, using the native windows api).
Please merge if you feel those are appropriate, thanks !