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 linked token resolution #9

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

Varbin
Copy link
Contributor

@Varbin Varbin commented Oct 15, 2021

By setting (websspi.Config).ResolveLinked there will be another *websspi.UserInfo placed in the request context with the key websspi.LinkedTokenUserInfoKey.

The example is extended to return both, the regular and linked token (emphasis is not in the example):

Hello BIEWALD\Administrator!

Groups:

  • Domain Users
  • Everyone
  • Users
  • INTERACTIVE
  • CONSOLE LOGON
  • Authenticated Users
  • This Organization
  • LOCAL
  • Security
  • Authentication authority asserted identity
  • Denied RODC Password Replication Group

Linked Token: BIEWALD\Administrator

Groups:
  • Domain Users
  • Everyone
  • Administrators
  • Users
  • Pre-Windows 2000 Compatible Access
  • INTERACTIVE
  • CONSOLE LOGON
  • Authenticated Users
  • This Organization
  • LOCAL
  • Domain Admins
  • Security
  • Group Policy Creator Owners
  • Enterprise Admins
  • Schema Admins
  • Authentication authority asserted identity
  • Denied RODC Password Replication Group

If the same site is requested from an elevated command, the tokens are swapped. Tests and improved documentation is missing, hence the draft status of this PR.

Closes #5.

This allows to pass the linked token without changing function
signatures.
It can be retrieved with
(*http.Request).Context().Value(websspi.LinkedTokenUserInfoKey).
@quasoft
Copy link
Owner

quasoft commented Oct 15, 2021

Thanks, at first glance it looks good. Thanks for your effort!

Will have more time to look it more detailed during the weekend.

Noticed a buffer holding the SID is allocated with 50 bytes. May be it would be reasonable to preserve 68 bytes just for the SID as that seems to be the maximum byte size of a user SID.

Copy link
Owner

@quasoft quasoft left a comment

Choose a reason for hiding this comment

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

May be we should extend a bit the comment in the doc.go file. Something like that should do:
websspi package implements a middleware for SSO Kerberos authentication of HTTP requests in Windows environments by SSPI, without the need for any keytab files

@@ -0,0 +1,4 @@
/*
Package websspi provides middleware to require with Windows Integrated Authentication.
Copy link
Owner

Choose a reason for hiding this comment

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

May be we should extend a bit the comment in the doc.go file. Something like that should do:

Suggested change
Package websspi provides middleware to require with Windows Integrated Authentication.
Package websspi implements a middleware for SSO Kerberos authentication of HTTP requests in Windows environments by SSPI, without the need for any keytab files

&usedMemory,
)

tokenuser := (*TokenUser)(unsafe.Pointer(&buffer[0]))
Copy link
Owner

Choose a reason for hiding this comment

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

It doesn't really matter, but we could first check the value of err, before setting the value of the tokenuser variable

if a.Config.ServerName == "" {
u.Groups, err = a.GetGroupsFromToken(linkedToken)
} else {
u.Groups, err = a.GetUserGroups(u.Username)
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure about this, but if u.Username is same for both the original Token and the LinkedToken, there won't be need to check for the direct groups again.

GetLinkedUserInfo is a new function, and if we agree that it does not need to be backwards compatible, you can make it completely ignore Config.ServerName value.

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.

Resolve linked token.
2 participants