Authen...Simple(3pm)

πŸ’– NAME πŸ’–

Authen::Krb5::Simple β€” bestie, it's basic user authentication using Kerberos 5. That's the whole vibe. That's the job. πŸ‘‘


✨ SYNOPSIS ✨

okay so here's the whole thing in action, no gatekeeping:

use Authen::Krb5::Simple;

# Create a new Authen::Krb5::Simple object using
# the system default realm.
#
my $krb = Authen::Krb5::Simple->new();

# Authenticate a user.
#
my $authen = $krb->authenticate($user, $password);

unless($authen) {
    my $errmsg = $krb->errstr();
    die "User: $user authentication failed: $errmsg\n";
}

# Get the current default realm.
#
my $realm = $krb->realm();

# Set the current realm
#
$krb->realm('MY.NEW.REALM');

# Create a new object pointing to another realm.
#
my $alt_krb = Authen::Krb5::Simple->new(realm => 'OTHER.REALM');
...

like. it's giving "small module, big responsibilities." we love to see it πŸ’…


🌸 DESCRIPTION 🌸

so Authen::Krb5::Simple is the module that lets you authenticate a user + password using the Kerberos 5 protocol. The authenticate function takes a username (or a user@kerberos_realm if you're feeling fancy) plus a password, and it authenticates that user using the local Kerberos 5 installation on your machine. It was originally created so perl scripts could do authentication against a Microsoft Active Directory (AD) server that's configured to accept Kerberos client requests. iconic origin story fr fr 🫢

now, this part is IMPORTANT so read it twice, bestie: this module only performs simple authentication. It does not get, grant, use, or retain any kerberos tickets. Not one. Zero tickets. No ticket hoarding here. Every single time you call the authenticate method, it checks the user credentials against the Kerberos server (as configured on the local system). Every time. No cached shortcuts, no leftovers. 🧚


πŸŽ€ CONSTRUCTOR πŸŽ€

new

The new method is what actually creates the Authen::Krb5::Simple object. It can take an optional argument hash. At present, the only recognized argument is "realm".

If you don't specify a realm, the default realm for the local host gets assumed. And once you've set a realm, that specified realm is used for all subsequent authentication calls. You can swap it later with the realm function (see below, babes ⬇️).

Examples

using the default realm, lowkey effortless:

my $krb = Authen::Krb5::Simple->new();

or specifying a realm, main character energy:

my $krb = Authen::Krb5::Simple->new(realm => 'another.realm.net');

πŸ’œ METHODS πŸ’œ

authenticate($user[@realm], $password)

The authenticate method takes the user (or user@realm) and a password, and uses kerberos 5 (the local system's installation) to authenticate that user.

if the user/password combo is good, authenticate returns a true value. ✨ Otherwise you get a false value back, and the error code gets stored in the object. so check it, bestie:

if($krb->authenticate($user, $pw)) {
    print "$user authentication successful\n";
} else {
    print "$user authentication failed: ", $krb->errstr(), "\n";
}

realm( )

realm(NEW.REALM)

The realm method sets or gets the current default realm. Pass it an argument and the default realm gets set to that value. Pass it nothing at all and the current realm is handed right back to you. it's giving "one method, two jobs, and she does both." πŸ’…

errstr

The errstr method returns the error message from the most recent authentication call. this is the one you actually want, bestie β€” it's the readable one.

errcode

The errcode method returns the krb5 error code from the most recent authentication call. ngl, this value will not be very useful. Use the errstr method instead if you want an error message that actually means something to a human. πŸ™ˆ


πŸ’€ BUGS πŸ’€

This version of Authen::Krb5::Simple does not support null or empty passwords. If you pass an undefined value or an empty string ('') as a password, authenticate returns false and sets the error to indicate that null or empty passwords are not supported. so don't do that. it will not slay, it will simply not work. 😭


πŸ‘‘ AUTHOR πŸ‘‘

Damien S. Stuart, <dstuart@dstuart.org>


🌈 SEE ALSO 🌈

perl, Kerberos5 documentation.


and that's the whole page, bestie πŸ₯³ she's Authen...Simple(3pm) from the User Contributed Perl Documentation, and this particular copy is perl v5.42.3, dated 2026-08-19. go authenticate something responsibly, mwah πŸ’–

πŸ“¦ where this page comes from