WebAuth::Krb5
WebAuth context for Kerberos calls
- Provided by: libwebauth-perl (Version: 4.5.5-2)
- Source: webauth
- Report a bug
WebAuth context for Kerberos calls
use WebAuth qw(:const);
use WebAuth::Krb5;
my $wa = WebAuth->new;
eval {
my $krb5 = WebAuth::Krb5->new ($wa);
$krb5->init_via_keytab ($path);
print $krb5->get_principal (WA_KRB5_CANON_LOCAL);
}
if ($@) {
# ... handle exception ...
}
This Perl context represents a WebAuth Kerberos context. This context is used to make all Kerberos-related calls and can also store a Kerberos identity and its corresponding ticket cache. A context is normally initiated with credentials from a username and password, a keytab, an existing ticket cache, or an exported credential.
A WebAuth::Krb5 object will be destroyed when the WebAuth context used to create it is destroyed, and subsequent accesses to it may cause memory access errors or other serious bugs. Be careful not to retain a copy of a WebAuth::Krb5 object after the WebAuth object that created it has been destroyed.
As with WebAuth module functions, failures are signaled by throwing WebAuth::Exception rather than by return status.
As with WebAuth module functions, failures are signaled by throwing WebAuth::Exception rather than by return status.
If WA_KRB5_CANON_LOCAL is specified but krb5_aname_to_localname returns an error, the fully-qualified principal will be returned.
If CANON is not specified, WA_KRB5_CANON_NONE is the default behavior.
PRINC specifies the principal for which to get tickets. If it is not specified, the first principal found in KEYTAB will be used.
If SPRINC is given, it specifies the principal in KEYTAB to use for the validation. If it is not specified, undef, or the empty string, the first principal found in KEYTAB will be used.
If PRINC is given and defined, obtain credentials for that principal rather than a TGT. This is normally used to get a context with a "kadmin/changepw" service ticket to use to change the user's password. If this is specified, the validity of the acquired credentials will not be verified.
If KEYTAB is not given, the validity of the returned tickets are not verified. This should only be used when obtaining "kadmin/changepw" service tickets to change a password. Skipping this validation step otherwise opens one up to KDC impersonation attacks.
Returns the server principal used to verify the TGT if KEYTAB is given and PRINC is not given. Otherwise, returns undef.
In a scalar context, returns the authenticator as binary data. In a list context, when DATA is given, returns a two-element list consisting of the authenticator and the encrypted DATA.
The returned client principal is canonicalized following the rule specified in CANON, following the same rules as in get_principal(). If CANON is not specified, WA_KRB5_CANON_NONE is the default behavior.
If EDATA is provided, it is decrypted with krb5_rd_priv, and the return value in a list context will be a two-element list containing the principal and the decrypted data.
Russ Allbery <rra@stanford.edu>
This module is part of WebAuth. The current version is available from <http://webauth.stanford.edu/>.