1Krb5(3) User Contributed Perl Documentation Krb5(3)
2
3
4
6 Authen::Krb5 - Perl extension for Kerberos 5
7
9 use Authen::Krb5;
10
11 Authen::Krb5::init_context();
12
14 Authen::Krb5 is an object oriented interface to the Kerberos 5 API.
15 Both the implementation and documentation are nowhere near complete,
16 and may require previous experience with Kerberos 5 programming. Most
17 of the functions here are documented in detail in the Kerberos 5 API
18 documentation.
19
20 FUNCTIONS
21
22 error(n)
23 Returns the error code from the most recent Authen::Krb5 call. If
24 provided with an error code 'n', this function will return a tex‐
25 tual description of the error.
26
27 init_context()
28 Initializes a context for the application. Returns a
29 Authen::Krb5::Context object, or undef if there was an error.
30
31 init_ets() (DEPRECATED)
32 Initializes the Kerberos error tables. Should be called along with
33 init_context at the beginning of a script.
34
35 get_default_realm()
36 Returns the default realm of your host.
37
38 get_host_realm(host)
39 Returns the realm of the specified host.
40
41 get_krbhst(realm)
42 Returns a list of the Kerberos servers from the specified realm.
43
44 build_principal_ext(p)
45 Not like the actual krb5_build_principal_ext. This is legacy code
46 from Malcolm's code, which I'll probably change in future releases.
47 In any case, it creates a 'server' principal for use in getting a
48 TGT. Pass it the principal for which you would like a TGT.
49
50 parse_name(name)
51 Converts a string representation of a principal to a principal
52 object. You can use this to create a principal from your username.
53
54 sname_to_principal(hostname,sname,type)
55 Generates a server principal from the given hostname, service, and
56 type. Type can be one of the following: NT_UNKNOWN, NT_PRINCIPAL,
57 NT_SRV_INST, NT_SRV_HST, NT_SRV_XHST, NT_UID. See the Kerberos
58 documentation for details.
59
60 cc_resolve(name)
61 Returns a credentials cache identifier which corresponds to the
62 given name. 'name' must be in the form TYPE:RESIDUAL. See the
63 Kerberos documentation for more information.
64
65 cc_default_name()
66 Returns the name of the default credentials cache, which may be
67 equivalent to KRB5CCACHE.
68
69 cc_default()
70 Returns a Authen::Krb5::Ccache object representing the default cre‐
71 dentials cache.
72
73 kt_resolve(name)
74 Returns a Authen::Krb5::Keytab object representing the specified
75 keytab name.
76
77 kt_default_name()
78 Returns a sting containing the default keytab name.
79
80 kt_default()
81 Returns an Authen::Krb5::Keytab object representing the default
82 keytab.
83
84 kt_read_service_key(name, principal[, kvno, enctype])
85 Searches the keytab specified by name (the default keytab if name
86 is undef) for a key matching principal (and optionally kvno and
87 enctype) and returns the key in the form of an Authen::Krb5::Key‐
88 block object.
89
90 get_init_creds_password(client, password[, service])
91 Attempt to get an initial ticket for the client. 'client' is a
92 principal object for which you want an initial ticket. 'password'
93 is the password for the client. 'service', if given, is the string
94 representation (not a principal object) for the ticket to acquire.
95 If not given, it defaults to krbtgt/REALM@REALM for the local
96 realm. Returns an Authen::Krb5::Creds object or undef on failure.
97
98 get_init_creds_keytab(client, keytab[, service])
99 Attempt to get an inintial ticket for the client using a keytab.
100 'client' is a principal object for which you want an initial
101 ticket. 'keytab' is a keytab object created with kt_resolve.
102 'service', if given, is the string representation (not a principal
103 object) for the ticket to acquire. If not given, it defaults to
104 krbtgt/REALM@REALM for the local realm. Returns an
105 Authen::Krb5::Creds object or undef on failure.
106
107 get_in_tkt_with_password(client,server,password,cc)
108 Attempt to get an initial ticket for the client. 'client' is a
109 principal object for which you want an initial ticket. 'server' is
110 a principal object for the service (usually krbtgt/REALM@REALM).
111 'password' is the password for the client, and 'cc' is a
112 Authen::Krb5::Ccache object representing the current credentials
113 cache. Returns a Kerberos error code.
114
115 Although this interface is deprecated in the Kerberos C libraries,
116 it's supported in the Perl module. In this module, it's imple‐
117 mented in terms of krb5_get_init_creds_password, krb5_cc_initial‐
118 ize, and krb5_cc_store_cred.
119
120 get_in_tkt_with_keytab(client,server,keytab,cc)
121 Obtain an initial ticket for the client using a keytab. 'client'
122 is a principal object for which you want an initial ticket.
123 'server' is a principal object for the service (usually
124 krbtgt/REALM@REALM). 'keytab' is a keytab object createed with
125 kt_resolve. 'cc' is a Authen::Krb5::Ccache object representing the
126 current credentials cache. Returns a Kerberos error code.
127
128 Although this interface is deprecated in the Kerberos C libraries,
129 it's supported in the Perl module. In this module, it's imple‐
130 mented in terms of krb5_get_init_creds_keytab, krb5_cc_initialize,
131 and krb5_cc_store_cred.
132
133 mk_req(auth_context,ap_req_options,service,hostname,in,cc)
134 Obtains a ticket for a specified service and returns a KRB_AP_REQ
135 message suitable for passing to rd_req. 'auth_context' is the
136 Authen::Krb5::AuthContext object you want to use for this connec‐
137 tion, 'ap_req_options' is an OR'ed representation of the possible
138 options (see Kerberos docs), 'service' is the name of the service
139 for which you want a ticket (like 'host'), hostname is the hostname
140 of the server, 'in' can be any user-specified data that can be ver‐
141 ified at the server end, and 'cc' is your credentials cache object.
142
143 rd_req(auth_context,in,server,keytab)
144 Parses a KRB_AP_REQ message and returns its contents in a
145 Authen::Krb5::Ticket object. 'auth_context' is the connection's
146 Authen::Krb5::AuthContext object, 'in' is the KRB_AP_REQ message
147 (usually from mk_req), and server is the expected server's name for
148 the ticket. 'keytab' is a Authen::Krb5::Keytab object for the
149 keytab you want to use. Specify 'undef' or leave off to use the
150 default keytab.
151
152 mk_priv(auth_context,in)
153 Encrypts 'in' using parameters specified in auth_context, and
154 returns the encrypted data. Requires use of a replay cache.
155
156 rd_priv(auth_context,in)
157 Decrypts 'in' using parameters specified in auth_context, and
158 returns the decrypted data.
159
160 sendauth(auth_context,fh,version,client,server,options,in,in_creds,cc)
161 Obtains and sends an authenticated ticket from a client program to
162 a server program using the filehandle 'fh'. 'version' is an appli‐
163 cation-defined version string that recvauth compares to its own
164 version string. 'client' is the client principal, e.g. user‐
165 name@REALM. 'server' is the service principal to which you are
166 authenticating, e.g. service.hostname@REALM. The only useful
167 option right now is AP_OPTS_MUTUAL_REQUIRED, which forces sendauth
168 to perform mutual authentication with the server. 'in' is a string
169 that will be received by recvauth and verified by the server--it's
170 up to the application. 'in_creds' is not yet supported, so just
171 use 'undef' here. 'cc' should be set to the current credentials
172 cache. sendauth returns true on success and undefined on failure.
173
174 recvauth(auth_context,fh,version,server,keytab)
175 Receives authentication data from a client using the sendauth func‐
176 tion through the filehandle 'fh'. 'version' is as described in the
177 sendauth section. 'server' is the server principal to which the
178 client will be authenticating. 'keytab' is a Authen::Krb5::Keytab
179 object specifying the keytab to use for this service. recvauth
180 returns a Authen::Krb5::Ticket object on success or undefined on
181 failure.
182
183 genaddrs(auth_context,fh,flags)
184 Uses the open socket filehandle 'fh' to generate local and remote
185 addresses for auth_context. Flags should be one of the following,
186 depending on the type of address you want to generate (flags can be
187 OR'ed):
188
189 KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR KRB5_AUTH_CONTEXT_GENER‐
190 ATE_LOCAL_FULL_ADDR KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR
191 KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR
192
193 gen_portaddr(addr,port)
194 Generates a local port address that can be used to name a replay
195 cache. 'addr' is a Authen::Krb5::Address object, and port is a
196 port number in network byte order. For generateing a replay cache
197 name, you should supply the local address of the client and the
198 socket's local port number. Returns a Authen::Krb5::Address object
199 containing the address.
200
201 gen_replay_name(addr,string)
202 Generate a unique replay cache name. 'addr' is a
203 Authen::Krb5::Address object created by gen_portaddr. 'string' is
204 used as a unique identifier for the replay cache. Returns the
205 replay cache name.
206
207 get_server_rcache(name)
208 Returns a Authen::Krb5::Rcache object using the replay cache name
209 'name.'
210
211 CLASSES & METHODS
212
213 Authen::Krb5::Principal
214 Kerberos 5 princpal object.
215
216 o realm
217 Returns the realm of the principal.
218
219 o type
220 Returns the type of the principal.
221
222 o data
223 Returns a list containing the components of the principal
224 (everything before the realm).
225
226 Authen::Krb5::Ccache
227 Kerberos 5 credentials cache object.
228
229 o initialize(p)
230 Creates/refreshes a credentials cache for the primary principal
231 'p'. If the cache already exists, its contents are destroyed.
232
233 o store_cred(creds)
234 Stores the given credentials, which should be an
235 Authen::Krb5::Creds object as returned from
236 get_init_creds_password() or get_init_creds_keytab(), in the
237 cache.
238
239 o get_name
240 Returns the name of the credentials cache.
241
242 o get_principal
243 Returns the primary principal of the credentials cache.
244
245 o destroy
246 Destroys the credentials cache and releases all resources it
247 used.
248
249 o start_seq_get()
250 Returns a cursor that can be passed to next_cred() to read in
251 turn every credential in the cache.
252
253 o next_cred(cursor)
254 Returns the next credential in the cache as an
255 Authen::Krb5::Creds object.
256
257 o end_seq_get(cursor)
258 Perform cleanup opreations after next_cred() and invalidates
259 cursor.
260
261 Authen::Krb5::KeyBlock
262 Kerberos 5 keyblock object.
263
264 o enctype()
265 Returns the encryption type ID.
266
267 o enctype_string()
268 Returns a text description of the encryption type.
269
270 o length()
271 Returns the length of the session key.
272
273 o contents()
274 Returns the actual contents of the keyblock (the session key).
275
276 Authen::Krb5::AuthContext
277 Kerberos 5 auth_context object.
278
279 o new
280 Allocates memory for a new Authen::Krb5::AuthContext object and
281 returns it.
282
283 o setaddrs(localaddr,remoteaddr)
284 Sets the local and remote addresses for the AuthContext object.
285 'localaddr' and 'remoteaddr' are Authen::Krb5::Address objects,
286 usually of type ADDRTYPE_INET.
287
288 o getaddrs()
289 Returns a list containing the local and the remote address of
290 the AuthContext object.
291
292 o setrcache(rc)
293 Sets the replay cache for auth_context. 'rc' is a
294 Authen::Krb5::Rcache object generated by get_server_rcache.
295
296 o getkey()
297 Retrieves the session key as an Authen::Krb5::KeyBlock object.
298
299 Authen::Krb5::Ticket
300 Kerberos 5 ticket object.
301
302 o server
303 Returns the server stored in the ticket.
304
305 o enc_part2
306 Returns a Authen::Krb5::EncTktPart object representation of the
307 ticket data. See below.
308
309 Authen::Krb5::EncTktPart
310 Object representation of the krb5_enc_tkt_part structure.
311
312 o client
313 The client principal contained in the ticket.
314
315 Authen::Krb5::Keyblock
316 Object representation of the krb5_keyblock structure.
317
318 o enctype
319 The integral enctype of the key.
320
321 o length
322 Length of the key.
323
324 o contents
325 Contents of the key itself, as a string.
326
327 Authen::Krb5::Keytab
328 o add_entry(entry)
329 Adds entry to the keytab.
330
331 o remove_entry(entry)
332 Removes entry from the keytab.
333
334 o get_name()
335 Returns the name of the keytab.
336
337 o get_entry(principal[, kvno, enctype])
338 Returns an Authen::Krb5::KeytabEntry object representing an
339 entry in the keytab matching principal and optionally kvno and
340 enctype.
341
342 o start_seq_get()
343 Returns a cursor that can be passed to next_entry() to read in
344 turn every key in the keytab.
345
346 o next_entry(cursor)
347 Returns the next entry in the keytab as an
348 Authen::Krb5::KeytabEntry object.
349
350 o end_seq_get(cursor)
351 Perform cleanup opreations after next_entry() and invalidates
352 cursor.
353
354 Authen::Krb5::KeytabEntry
355 o new(principal, kvno, keyblock)
356 Create a new Authen::Krb5::KeytabEntry object from an
357 Authen::Krb5::Principal object, a key version number, and an
358 Authen::Krb5::Keyblock object.
359
360 o principal
361 An Authen::Krb5::Principal object representing the principal
362 contained in the entry.
363
364 o timestamp
365 The timestamp of the entry.
366
367 o kvno
368 The key version number of the key contained in the entry.
369
370 o key
371 An Authen::Krb5::Keyblock object representing a copy of the
372 keyblock contained in the entry.
373
375 Jeff Horwitz (jeff@laserlink.net)
376
378 Based on the original work by Doug MacEachern and Malcolm Beattie.
379 Code contributions from Scott Hutton (shutton@indiana.edu).
380
382 perl(1), kerberos(1).
383
384
385
386perl v5.8.8 2008-01-03 Krb5(3)