Discussion:
[Freeipa-devel] [freeipa PR#638][opened] ipalib/rpc.py: Fix session handling for KEYRING: ccaches
abbra
2017-03-22 13:45:35 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Author: abbra
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches
Action: opened

PR body:
"""
MIT Kerberos allows to store configuration entries in the ccache.
Unfortunately, there are big differences between ccache types in how
these entries behave:

- MIT Kerberos FILE: ccache code does always append entries, so we end
up with ever growing ccache files. In KEYRING: case we are lucky that
add_key syscall actually updates the key with the same name.

- MIT Kerberos FILE: and KEYRING: ccache code does not allow to remove
cred from ccache. Corresponding functions simply return
KRB5_CC_NOSUPP;

As result, using FILE: ccache type does not allow us to override our
session cookie stored as a config entry in the ccache. Successive runs
of ipa CLI create new entries in the ccache and only return the original
one.

Once we put a cookie in the FILE: ccache, it cannot be removed from
there and cannot be replaced. Also, as retrieval code in
krb5_cc_get_conf() ends up calling krb5_cc_retrieve_cred() with 0 flags
and only has a cred principal name constructed out of a our conf key
(X-IPA-Session_Cookie), none of the matching logic for "most recent
ticket" could be applied.

This commit attempts to improve situation for KEYRING: ccache type by
setting the cookie to a predefined 'empty' value when deleting config
entry. This avoids non-working 'remove cred' code path in ccache
processing in MIT Kerberos.

Additionally, when server side denies our cookie, it sends us empty
Negotiate value. We errorneously treat it as invalid token.

We also must use proper method to initialize our connection,
SSLTransport.make_connection knows nothing about setting up GSSAPI
client context, KrbTransport does. Unfortunately, with non-removable
session cookie the code to initialize session context never triggered
properly after expire.

Fixes https://pagure.io/freeipa/issue/6775
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/638/head:pr638
git checkout pr638
abbra
2017-03-22 13:45:51 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches

abbra commented:
"""
Note: this is WIP, please test it against KEYRING: ccaches.
"""

See the full comment at https://github.com/freeipa/freeipa/pull/638#issuecomment-288402486
simo5
2017-03-22 13:58:39 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches

simo5 commented:
"""
One way to deal with this in the FILE case is to copy the ccache to a tmp file and then rename to the original one. There is a risk of racing and removing a new ticket, but it is low.

Luckily this problem should be solved once we have KCM caches ...
"""

See the full comment at https://github.com/freeipa/freeipa/pull/638#issuecomment-288406237
abbra
2017-03-22 14:06:51 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches

abbra commented:
"""
Yes, KCM will work. However, I wonder if we could use a different approach by storing cookie in a fake ticket with a proper lifetime set to the cookie expiration. This would still get multiple entries added for FILE: case but at least will allow us to return most recent one.
"""

See the full comment at https://github.com/freeipa/freeipa/pull/638#issuecomment-288408872
simo5
2017-03-23 20:31:01 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches

simo5 commented:
"""
This PR has been obsoleted by #649
"""

See the full comment at https://github.com/freeipa/freeipa/pull/638#issuecomment-288850585
simo5
2017-03-23 20:31:04 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/638
Author: abbra
Title: #638: ipalib/rpc.py: Fix session handling for KEYRING: ccaches
Action: closed

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/638/head:pr638
git checkout pr638

Loading...