Authen::Krb5(3pm)
π Authen::Krb5 π
okay bestie, gather round, because we're talking about Authen::Krb5 β that's the XS bindings for Kerberos 5, and yes she's a 3pm page, a User Contributed Perl Documentation girly through and through. β¨
πΈ VERSION πΈ
version 1.906 β that's the one, no cap.
π SYNOPSIS π
use Authen::Krb5;
Authen::Krb5::init_context();
like. that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
So "Authen::Krb5" is an object oriented interface to the Kerberos 5 API. Iconic. But real talk: both the implementation and the documentation are nowhere near complete, and using this may require previous experience with Kerberos 5 programming. She's not holding your hand, she's holding your ticket. π
Most of the functions here are documented in detail in the Kerberos 5 API documentation over at <http://web.mit.edu/kerberos/krb5-current/doc/appdev/refs/api/index.html> β go read that, iykyk. π
β¨ FUNCTIONS β¨
error(n)β returns the error code from the most recent"Authen::Krb5"call. And if you hand her an error coden? She gives you back a textual description of that error. bilingual queen. πinit_context()β initializes a context for the application. Returns a"Authen::Krb5::Context"object, orundefif there was an error. π"init_ets() (DEPRECATED)"β initializes the Kerberos error tables. Should be called along with"init_context()"at the beginning of a script. She's deprecated but she's still showing up to the function. πget_default_realm()β returns the default realm of your host.get_host_realm(host)β returns the realm of the specified host.get_krbhst(realm)β returns a list of the Kerberos servers from the specified realm.build_principal_ext(p)β okay so she is not like the actual"krb5_build_principal_ext", and I need you to know that. This is legacy code from Malcolm's code, which the author will probably change in future releases. In any case, it creates a 'server' principal for use in getting a TGT. Pass it the principal for which you would like a TGT. ποΈparse_name(name)β converts a string representation of a principal to a principal object. You can use this to create a principal from your username. main character move, honestly."sname_to_principal(hostname,sname,type)"β generates a server principal from the given hostname, service, and type. Type can be one of the following:NT_UNKNOWN,NT_PRINCIPAL,NT_SRV_INST,NT_SRV_HST,NT_SRV_XHST,NT_UID. See the Kerberos documentation for details. πcc_resolve(name)β returns a credentials cache identifier which corresponds to the given name.'name'must be in the formTYPE:RESIDUAL. See the Kerberos documentation for more information.cc_default_name()β returns the name of the default credentials cache, which may be equivalent toKRB5CCACHE.cc_default()β returns aAuthen::Krb5::Ccacheobject representing the default credentials cache. π«Άkt_resolve(name)β returns aAuthen::Krb5::Keytabobject representing the specified keytab name.kt_default_name()β returns a string containing the default keytab name.kt_default()β returns anAuthen::Krb5::Keytabobject representing the default keytab."kt_read_service_key(name, principal[, kvno, enctype])"β searches the keytab specified by name (the default keytab if name isundef) for a key matching principal (and optionally kvno and enctype) and returns the key in the form of anAuthen::Krb5::Keyblockobject. π"get_init_creds_password(client, password[, service])"β attempt to get an initial ticket for the client.'client'is a principal object for which you want an initial ticket.'password'is the password for the client.'service', if given, is the string representation (not a principal object, bestie, read that again) for the ticket to acquire. If not given, it defaults to"krbtgt/REALM@REALM"for the local realm. Returns anAuthen::Krb5::Credsobject orundefon failure. π"get_init_creds_keytab(client, keytab[, service])"β attempt to get an initial ticket for the client using a keytab.'client'is a principal object for which you want an initial ticket.'keytab'is a keytab object created withkt_resolve.'service', if given, is the string representation (not a principal object) for the ticket to acquire. If not given, it defaults to"krbtgt/REALM@REALM"for the local realm. Returns anAuthen::Krb5::Credsobject orundefon failure. β¨"get_in_tkt_with_password(client,server,password,cc)"β attempt to get an initial ticket for the client.'client'is a principal object for which you want an initial ticket.'server'is a principal object for the service (usually"krbtgt/REALM@REALM").'password'is the password for the client, and'cc'is aAuthen::Krb5::Ccacheobject representing the current credentials cache. Returns a Kerberos error code.
Although this interface is deprecated in the Kerberos C libraries, it's supported in the Perl module. In this module, it's implemented in terms of"krb5_get_init_creds_password",krb5_cc_initialize, andkrb5_cc_store_cred.
"get_in_tkt_with_keytab(client,server,keytab,cc)"β obtain an initial ticket for the client using a keytab.'client'is a principal object for which you want an initial ticket.'server'is a principal object for the service (usually"krbtgt/REALM@REALM").'keytab'is a keytab object created withkt_resolve.'cc'is aAuthen::Krb5::Ccacheobject representing the current credentials cache. Returns a Kerberos error code.
Although this interface is deprecated in the Kerberos C libraries, it's supported in the Perl module. In this module, it's implemented in terms ofkrb5_get_init_creds_keytab,krb5_cc_initialize, andkrb5_cc_store_cred.
"mk_req(auth_context,ap_req_options,service,hostname,in,cc)"β obtains a ticket for a specified service and returns a"KRB_AP_REQ"message suitable for passing tord_req.'auth_context'is theAuthen::Krb5::AuthContextobject you want to use for this connection,'ap_req_options'is an OR'ed representation of the possible options (see Kerberos docs),'service'is the name of the service for which you want a ticket (like'host'), hostname is the hostname of the server,'in'can be any user-specified data that can be verified at the server end, and'cc'is your credentials cache object. π"rd_req(auth_context,in,server,keytab)"β parses a"KRB_AP_REQ"message and returns its contents in aAuthen::Krb5::Ticketobject.'auth_context'is the connection'sAuthen::Krb5::AuthContextobject,'in'is the"KRB_AP_REQ"message (usually frommk_req), and server is the expected server's name for the ticket.'keytab'is aAuthen::Krb5::Keytabobject for the keytab you want to use. Specify"undef"or leave off to use the default keytab. ποΈ"mk_priv(auth_context,in)"β encrypts'in'using parameters specified in auth_context, and returns the encrypted data. Requires use of a replay cache. π₯"rd_priv(auth_context,in)"β decrypts'in'using parameters specified in auth_context, and returns the decrypted data."sendauth(auth_context,fh,version,client,server,options,in,in_creds,cc)"β obtains and sends an authenticated ticket from a client program to a server program using the filehandle'fh'.'version'is an application-defined version string thatrecvauthcompares to its own version string.'client'is the client principal, e.g."username@REALM".'server'is the service principal to which you are authenticating, e.g."service.hostname@REALM". The only useful option right now is"AP_OPTS_MUTUAL_REQUIRED", which forcessendauthto perform mutual authentication with the server.'in'is a string that will be received byrecvauthand verified by the server β it's up to the application.'in_creds'is not yet supported, so just use'undef'here.'cc'should be set to the current credentials cache.sendauthreturns true on success and undefined on failure. π"recvauth(auth_context,fh,version,server,keytab)"β receives authentication data from a client using thesendauthfunction through the filehandle'fh'.'version'is as described in thesendauthsection.'server'is the server principal to which the client will be authenticating.'keytab'is a"Authen::Krb5::Keytab"object specifying the keytab to use for this service.recvauthreturns a"Authen::Krb5::Ticket"object on success or undefined on failure. π«Ά"genaddrs(auth_context,fh,flags)"β uses the open socket filehandle'fh'to generate local and remote addresses for auth_context. Flags should be one of the following, depending on the type of address you want to generate (flags can be OR'ed):
KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR
KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR
KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR
KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR
"gen_portaddr(addr,port)"β generates a local port address that can be used to name a replay cache.'addr'is aAuthen::Krb5::Addressobject, and port is a port number in network byte order. For generating a replay cache name, you should supply the local address of the client and the socket's local port number. Returns aAuthen::Krb5::Addressobject containing the address. π§"gen_replay_name(addr,string)"β generate a unique replay cache name.'addr'is aAuthen::Krb5::Addressobject created bygen_portaddr.'string'is used as a unique identifier for the replay cache. Returns the replay cache name. βget_server_rcache(name)β returns aAuthen::Krb5::Rcacheobject using the replay cache name'name.'π
π ACKNOWLEDGEMENTS π
Based on the original work by Doug MacEachern and Malcolm Beattie. Code contributions from Scott Hutton (shutton@indiana.edu). giving credit where credit is due, we love to see it. π«Ά
π SEE ALSO π
perl(1), kerberos(1).
π AUTHOR π
Jeff Horwitz <jeff@smashing.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2000 by Jeff Horwitz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie!! π this one shipped as Authen::Krb5(3pm) under perl v5.40.1, dated 2025-04-11 β she's a User Contributed Perl Documentation girly and she ate. periodt. β¨ππ¦
π¦ where this page comes from
- debian trixie: libauthen-krb5-perl 1.906-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libauthen-krb5-perl 1.906-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms