Authen::Credential(3)
π Authen::Credential π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's literally all about Authen::Credential β the icon, the moment, the credential abstraction itself. grab a strawberry drink and let's get into it π
β¨ NAME β¨
Authen::Credential β abstraction of a credential. that's it, that's the vibe. π
π SYNOPSIS π
use Authen::Credential;
use Authen::Credential::plain;
use Getopt::Long qw(GetOptions);
use Config::General qw(ParseConfig);
use HTTP::Request;
# creation
$cred = Authen::Credential->new(
scheme => "plain",
name => "system",
pass => "manager",
);
# idem directly using the sub-class
$cred = Authen::Credential::plain->new(
name => "system",
pass => "manager",
);
# get credential from command line option
GetOptions(\%Option,
"auth=s",
...
);
$cred = Authen::Credential->parse($Option{auth});
# get credential from configuration file
%Option = ParseConfig(-ConfigFile => "...");
$cred = Authen::Credential->new($Option{auth});
# access the credential attributes
if ($cred->scheme() eq "plain") {
printf("user name is %s\n", $cred->name());
}
# use the prepare() method to get ready-to-use data
$req = HTTP::Request->new(GET => $url);
$req->header(Authorization => $cred->prepare("HTTP.Basic"));
no cap, that's the whole glow-up in one block. π
π DESCRIPTION π
so like, this module hands you abstractions of credentials β meaning a thing you can use to authenticate, bestie. it lets you create and manipulate credentials. and it's not just vibing, it's structured:
- it defines a standard string representation, so credentials can be handed to external programs as command line options
- it defines a standard structured representation, so credentials can live in structured configuration files or in JSON
- it gives you "preparators" that transform credentials into ready-to-use data for well known targets
different authentication schemes (aka credential types, same thing different name, iykyk) are supported. right now this package supports "none", "plain" and "x509" β but more can be added by providing the supporting code in a separate module. very main character energy of you tbh. β¨
there's also a Python implementation of the same credential abstractions living at https://github.com/cern-mig/python-auth-credential, so credentials can be shared between different programming languages. multilingual queen. π
for a given scheme, a credential is represented by an object with a fixed set of string attributes. for instance, the "plain" scheme has two attributes: name and pass. more info lives in the scheme specific module, for instance Authen::Credential::plain. π¦
πΈ STRING REPRESENTATION πΈ
the string representation of a credential is made of its scheme followed by its attributes as key=value pairs, seperated by space.
for instance, for the "none" scheme with no attributes:
none
and the the "plain" scheme with a name and password:
plain name=system pass=manager
if needed, the characters can be URI-escaped, see URI::Escape. all non-alphanumerical characters should be escaped to avoid parsing ambiguities. don't skip that part, it's giving chaos otherwise. π
the string representation is useful to give a program through its command line options. for instance:
myprog --uri http://foo:80 --auth "plain name=system pass=manager"
π§ STRUCTURED REPRESENTATION π§
the structured representation of a credential is made of its scheme and all its attributes as a string table. a whole little organized baddie. π
here is for instance how it could end up using JSON:
{"scheme":"plain","name":"system","pass":"manager"}
the same information could be stored in a configuration file. here is an example using the Apache syntax, which is for instance supported by Config::General:
<auth>
scheme = plain
name = system
pass = manager
</auth>
π METHODS π
this module supports the following methods, and bestie they all ate:
new([OPTIONS])β return a new credential object (class method); the OPTIONS are its attributesparse(STRING)β return a new credential object from its string representation (class method)hash()β return its structured representation as a reference to a hashstring()β return its string representationcheck()β check that the credential contains the expected attributesprepare(TARGET)β use the credential to prepare data for a given target (this is scheme specific)scheme()β return the authentication scheme of the credential
in addition, the attributes can be accessed using eponymous methods. see the example in the "SYNOPSIS" section. π«Ά
β SEE ALSO β
Authen::Credential::noneAuthen::Credential::plainAuthen::Credential::x509URI::Escape
go read those too, they're the supporting cast and they're all iconic. π
π AUTHOR π
Lionel Cons <http://cern.ch/lionel.cons>
Copyright (C) CERN 2011-2015
okay that's the whole page, you're officially credential-literate, no cap. this one's perl v5.42.0, dated 2025-07-25, and it lives at Authen::Credential(3) β go forth and authenticate, queen. π
β¨π
π¦ where this page comes from
- fedora 43: perl-Authen-Credential 1.2-13.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms