I need to support Kerberos constrained delegation for our C++ HTTP server product on Windows using SSPI.
For a single process server, the follow workflow can be used and I have a working prototype.
1) Call AcquireCredentialsHandle
2) Call AcceptSecurityContext
3) Call ImpersonateSecurityContext
4) Do delegation
5) Call RevertSecurityContext
However, the C++ HTTP server has a master process and a worker process. Both processes run on the same machine and use the same service account, and each client request can come from a different user. The master process can handle SPNEGO and Kerberos authentication using AcquireCredentialsHandle and AcceptSecurityContext, but it has no knowledge of which resource it needs to delegate, only the worker process has the knowledge.
Which SSPIs can I use to forward the client's security context to the worker so that the worker can do impersonation/delegation?
Seems one possible solution is to get client's identity in the master, transfer that to the worker; then in the worker use LsaLogonUser and ImpersonateLoggedOnUser. However, since LsaLogonUser allows logon without password, our security expert is strongly against the use of it.
SSPI also has ExportSecurityContext and ImportSecurityContext, but the documentation is very vague and not sure if it can address my use case. Since the ImpersonateSecurityContext documentation says it "allows a server to impersonate a client by using a token previously obtained by a call to AcceptSecurityContext (General) or QuerySecurityContextToken.", seems I can't call ImpersonateSecurityContext after ImportSecurityContext.
Any suggestion is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…