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

Respect krb5_principal when impersonating #111

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Respect krb5_principal when impersonating #111

merged 1 commit into from
Feb 11, 2025

Conversation

sesse
Copy link

@sesse sesse commented Feb 10, 2025

When doing impersonation, we need to get initial credentials using some service principal from the given keytab. However, since keytabs have no default principals, libgss just chooses the first one in the file, which generally does not work well when in Active Directory.

In particular, in AD, the only valid principal for authenticating is [email protected], whereas e.g. host/[email protected] is just an SPN connected to SERVER$ and not valid for authenticating in its own right. gssd will try SERVER$ first for its own purposes (at least according to the man page), but when impersonating, it will naturally ask for a ticket for a user (e.g. [email protected]) and not the service principal itself.

This patch doesn't really make us choose the right principal for AD purposes, but it makes us respect the krb5_principal configuration option when getting a service principal for this purpose, so that an administrator can at least manually select which one to use without having to somehow reorder entries in the keytab (which appears to be hard). Thus, the admin can set "krb5_principal = [email protected]" in the service definition in gssproxy.conf, and it will work.

@simo5
Copy link
Contributor

simo5 commented Feb 10, 2025

Sigh apparently the latest ubuntu image broke the CI, lemme try to fix it

@simo5
Copy link
Contributor

simo5 commented Feb 11, 2025

Hi @sesse would you mind rebasing on top of main so we can run the CI (I fixed it).

When doing impersonation, we need to get initial credentials
using some service principal from the given keytab. However,
since keytabs have no default principals, libgss just chooses
the first one in the file, which generally does not work well
when in Active Directory.

In particular, in AD, the only valid principal for authenticating
is [email protected], whereas e.g. host/[email protected]
is just an SPN connected to SERVER$ and not valid for authenticating
in its own right. gssd will try SERVER$ first for its own purposes
(at least according to the man page), but when impersonating,
it will naturally ask for a ticket for a user (e.g. [email protected])
and not the service principal itself.

This patch doesn't really make us choose the right principal for
AD purposes, but it makes us respect the krb5_principal configuration
option when getting a service principal for this purpose, so that
an administrator can at least manually select which one to use
without having to somehow reorder entries in the keytab (which appears
to be hard). Thus, the admin can set "krb5_principal = [email protected]"
in the service definition in gssproxy.conf, and it will work.

Signed-off-by: Steinar H. Gunderson <[email protected]>
@simo5
Copy link
Contributor

simo5 commented Feb 11, 2025

Thanks for the contribution

@simo5 simo5 merged commit 66e7c5c into gssapi:main Feb 11, 2025
5 checks passed
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.

2 participants