xref: /freebsd/crypto/krb5/doc/basic/ccache_def.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert.. _ccache_definition:
2*7f2fe78bSCy Schubert
3*7f2fe78bSCy SchubertCredential cache
4*7f2fe78bSCy Schubert================
5*7f2fe78bSCy Schubert
6*7f2fe78bSCy SchubertA credential cache (or "ccache") holds Kerberos credentials while they
7*7f2fe78bSCy Schubertremain valid and, generally, while the user's session lasts, so that
8*7f2fe78bSCy Schubertauthenticating to a service multiple times (e.g., connecting to a web
9*7f2fe78bSCy Schubertor mail server more than once) doesn't require contacting the KDC
10*7f2fe78bSCy Schubertevery time.
11*7f2fe78bSCy Schubert
12*7f2fe78bSCy SchubertA credential cache usually contains one initial ticket which is
13*7f2fe78bSCy Schubertobtained using a password or another form of identity verification.
14*7f2fe78bSCy SchubertIf this ticket is a ticket-granting ticket, it can be used to obtain
15*7f2fe78bSCy Schubertadditional credentials without the password.  Because the credential
16*7f2fe78bSCy Schubertcache does not store the password, less long-term damage can be done
17*7f2fe78bSCy Schubertto the user's account if the machine is compromised.
18*7f2fe78bSCy Schubert
19*7f2fe78bSCy SchubertA credentials cache stores a default client principal name, set when
20*7f2fe78bSCy Schubertthe cache is created.  This is the name shown at the top of the
21*7f2fe78bSCy Schubert:ref:`klist(1)` *-A* output.
22*7f2fe78bSCy Schubert
23*7f2fe78bSCy SchubertEach normal cache entry includes a service principal name, a client
24*7f2fe78bSCy Schubertprincipal name (which, in some ccache types, need not be the same as
25*7f2fe78bSCy Schubertthe default), lifetime information, and flags, along with the
26*7f2fe78bSCy Schubertcredential itself.  There are also other entries, indicated by special
27*7f2fe78bSCy Schubertnames, that store additional information.
28*7f2fe78bSCy Schubert
29*7f2fe78bSCy Schubert
30*7f2fe78bSCy Schubertccache types
31*7f2fe78bSCy Schubert------------
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy SchubertThe credential cache interface, like the :ref:`keytab_definition` and
34*7f2fe78bSCy Schubert:ref:`rcache_definition` interfaces, uses `TYPE:value` strings to
35*7f2fe78bSCy Schubertindicate the type of credential cache and any associated cache naming
36*7f2fe78bSCy Schubertdata to use.
37*7f2fe78bSCy Schubert
38*7f2fe78bSCy SchubertThere are several kinds of credentials cache supported in the MIT
39*7f2fe78bSCy SchubertKerberos library.  Not all are supported on every platform.  In most
40*7f2fe78bSCy Schubertcases, it should be correct to use the default type built into the
41*7f2fe78bSCy Schubertlibrary.
42*7f2fe78bSCy Schubert
43*7f2fe78bSCy Schubert#. **API** is only implemented on Windows.  It communicates with a
44*7f2fe78bSCy Schubert   server process that holds the credentials in memory for the user,
45*7f2fe78bSCy Schubert   rather than writing them to disk.
46*7f2fe78bSCy Schubert
47*7f2fe78bSCy Schubert#. **DIR** points to the storage location of the collection of the
48*7f2fe78bSCy Schubert   credential caches in *FILE:* format. It is most useful when dealing
49*7f2fe78bSCy Schubert   with multiple Kerberos realms and KDCs.  For release 1.10 the
50*7f2fe78bSCy Schubert   directory must already exist.  In post-1.10 releases the
51*7f2fe78bSCy Schubert   requirement is for parent directory to exist and the current
52*7f2fe78bSCy Schubert   process must have permissions to create the directory if it does
53*7f2fe78bSCy Schubert   not exist. See :ref:`col_ccache` for details.  New in release 1.10.
54*7f2fe78bSCy Schubert   The following residual forms are supported:
55*7f2fe78bSCy Schubert
56*7f2fe78bSCy Schubert   * DIR:dirname
57*7f2fe78bSCy Schubert   * DIR::dirpath/filename - a single cache within the directory
58*7f2fe78bSCy Schubert
59*7f2fe78bSCy Schubert   Switching to a ccache of the latter type causes it to become the
60*7f2fe78bSCy Schubert   primary for the directory.
61*7f2fe78bSCy Schubert
62*7f2fe78bSCy Schubert#. **FILE** caches are the simplest and most portable. A simple flat
63*7f2fe78bSCy Schubert   file format is used to store one credential after another.  This is
64*7f2fe78bSCy Schubert   the default ccache type if no type is specified in a ccache name.
65*7f2fe78bSCy Schubert
66*7f2fe78bSCy Schubert#. **KCM** caches work by contacting a daemon process called ``kcm``
67*7f2fe78bSCy Schubert   to perform cache operations.  If the cache name is just ``KCM:``,
68*7f2fe78bSCy Schubert   the default cache as determined by the KCM daemon will be used.
69*7f2fe78bSCy Schubert   Newly created caches must generally be named ``KCM:uid:name``,
70*7f2fe78bSCy Schubert   where *uid* is the effective user ID of the running process.
71*7f2fe78bSCy Schubert
72*7f2fe78bSCy Schubert   KCM client support is new in release 1.13.  A KCM daemon has not
73*7f2fe78bSCy Schubert   yet been implemented in MIT krb5, but the client will interoperate
74*7f2fe78bSCy Schubert   with the KCM daemon implemented by Heimdal.  macOS 10.7 and higher
75*7f2fe78bSCy Schubert   provides a KCM daemon as part of the operating system, and the
76*7f2fe78bSCy Schubert   **KCM** cache type is used as the default cache on that platform in
77*7f2fe78bSCy Schubert   a default build.
78*7f2fe78bSCy Schubert
79*7f2fe78bSCy Schubert#. **KEYRING** is Linux-specific, and uses the kernel keyring support
80*7f2fe78bSCy Schubert   to store credential data in unswappable kernel memory where only
81*7f2fe78bSCy Schubert   the current user should be able to access it.  The following
82*7f2fe78bSCy Schubert   residual forms are supported:
83*7f2fe78bSCy Schubert
84*7f2fe78bSCy Schubert   * KEYRING:name
85*7f2fe78bSCy Schubert   * KEYRING:process:name - process keyring
86*7f2fe78bSCy Schubert   * KEYRING:thread:name -  thread keyring
87*7f2fe78bSCy Schubert
88*7f2fe78bSCy Schubert   Starting with release 1.12 the *KEYRING* type supports collections.
89*7f2fe78bSCy Schubert   The following new residual forms were added:
90*7f2fe78bSCy Schubert
91*7f2fe78bSCy Schubert   * KEYRING:session:name - session keyring
92*7f2fe78bSCy Schubert   * KEYRING:user:name - user keyring
93*7f2fe78bSCy Schubert   * KEYRING:persistent:uidnumber - persistent per-UID collection.
94*7f2fe78bSCy Schubert     Unlike the user keyring, this collection survives after the user
95*7f2fe78bSCy Schubert     logs out, until the cache credentials expire.  This type of
96*7f2fe78bSCy Schubert     ccache requires support from the kernel; otherwise, it will fall
97*7f2fe78bSCy Schubert     back to the user keyring.
98*7f2fe78bSCy Schubert
99*7f2fe78bSCy Schubert   See :ref:`col_ccache` for details.
100*7f2fe78bSCy Schubert
101*7f2fe78bSCy Schubert#. **MEMORY** caches are for storage of credentials that don't need to
102*7f2fe78bSCy Schubert   be made available outside of the current process.  For example, a
103*7f2fe78bSCy Schubert   memory ccache is used by :ref:`kadmin(1)` to store the
104*7f2fe78bSCy Schubert   administrative ticket used to contact the admin server.  Memory
105*7f2fe78bSCy Schubert   ccaches are faster than file ccaches and are automatically
106*7f2fe78bSCy Schubert   destroyed when the process exits.
107*7f2fe78bSCy Schubert
108*7f2fe78bSCy Schubert#. **MSLSA** is a Windows-specific cache type that accesses the
109*7f2fe78bSCy Schubert   Windows credential store.
110*7f2fe78bSCy Schubert
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy Schubert.. _col_ccache:
113*7f2fe78bSCy Schubert
114*7f2fe78bSCy SchubertCollections of caches
115*7f2fe78bSCy Schubert---------------------
116*7f2fe78bSCy Schubert
117*7f2fe78bSCy SchubertSome credential cache types can support collections of multiple
118*7f2fe78bSCy Schubertcaches.  One of the caches in the collection is designated as the
119*7f2fe78bSCy Schubert*primary* and will be used when the collection is resolved as a cache.
120*7f2fe78bSCy SchubertWhen a collection-enabled cache type is the default cache for a
121*7f2fe78bSCy Schubertprocess, applications can search the specified collection for a
122*7f2fe78bSCy Schubertspecific client principal, and GSSAPI applications will automatically
123*7f2fe78bSCy Schubertselect between the caches in the collection based on criteria such as
124*7f2fe78bSCy Schubertthe target service realm.
125*7f2fe78bSCy Schubert
126*7f2fe78bSCy SchubertCredential cache collections are new in release 1.10, with support
127*7f2fe78bSCy Schubertfrom the **DIR** and **API** ccache types.  Starting in release 1.12,
128*7f2fe78bSCy Schubertcollections are also supported by the **KEYRING** ccache type.
129*7f2fe78bSCy SchubertCollections are supported by the **KCM** ccache type in release 1.13.
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert
132*7f2fe78bSCy SchubertTool alterations to use cache collection
133*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134*7f2fe78bSCy Schubert
135*7f2fe78bSCy Schubert* :ref:`kdestroy(1)` *-A* will destroy all caches in the collection.
136*7f2fe78bSCy Schubert* If the default cache type supports switching, :ref:`kinit(1)`
137*7f2fe78bSCy Schubert  *princname* will search the collection for a matching cache and
138*7f2fe78bSCy Schubert  store credentials there, or will store credentials in a new unique
139*7f2fe78bSCy Schubert  cache of the default type if no existing cache for the principal
140*7f2fe78bSCy Schubert  exists.  Either way, kinit will switch to the selected cache.
141*7f2fe78bSCy Schubert* :ref:`klist(1)` *-l* will list the caches in the collection.
142*7f2fe78bSCy Schubert* :ref:`klist(1)` *-A* will show the content of all caches in the
143*7f2fe78bSCy Schubert  collection.
144*7f2fe78bSCy Schubert* :ref:`kswitch(1)` *-p princname* will search the collection for a
145*7f2fe78bSCy Schubert  matching cache and switch to it.
146*7f2fe78bSCy Schubert* :ref:`kswitch(1)` *-c cachename* will switch to a specified cache.
147*7f2fe78bSCy Schubert
148*7f2fe78bSCy Schubert
149*7f2fe78bSCy SchubertDefault ccache name
150*7f2fe78bSCy Schubert-------------------
151*7f2fe78bSCy Schubert
152*7f2fe78bSCy SchubertThe default credential cache name is determined by the following, in
153*7f2fe78bSCy Schubertdescending order of priority:
154*7f2fe78bSCy Schubert
155*7f2fe78bSCy Schubert#. The **KRB5CCNAME** environment variable.  For example,
156*7f2fe78bSCy Schubert   ``KRB5CCNAME=DIR:/mydir/``.
157*7f2fe78bSCy Schubert
158*7f2fe78bSCy Schubert#. The **default_ccache_name** profile variable in :ref:`libdefaults`.
159*7f2fe78bSCy Schubert
160*7f2fe78bSCy Schubert#. The hardcoded default, |ccache|.
161