Authen...:Client(3pm)
π NAME π
okay so bestie, meet Authen::CAS::Client β it's a whole module (a 3pm manual page from the User Contributed Perl Documentation, no less) that gives you an easy-to-use interface for authentication using JA-SIG's Central Authentication Service. CAS. Yeah. That one. π
β¨ SYNOPSIS β¨
the vibe, in code:
use Authen::CAS::Client;
my $cas = Authen::CAS::Client->new( 'https://example.com/cas' );
# generate an HTTP redirect to the CAS login URL
my $r = HTTP::Response->new( 302 );
$r->header( Location => $cas->login_url );
# generate an HTTP redirect to the CAS logout URL
my $r = HTTP::Response->new( 302 );
$r->header( Location => $cas->logout_url );
# validate a service ticket (CAS v1.0)
my $r = $cas->validate( $service, $ticket );
if( $r->is_success ) {
print "User authenticated as: ", $r->user, "\n";
}
# validate a service ticket (CAS v2.0)
my $r = $cas->service_validate( $service, $ticket );
if( $r->is_success ) {
print "User authenticated as: ", $r->user, "\n";
}
# validate a service/proxy ticket (CAS v2.0)
my $r = $cas->proxy_validate( $service, $ticket );
if( $r->is_success ) {
print "User authenticated as: ", $r->user, "\n";
print "Proxied through:\n";
print " $_\n"
for $r->proxies;
}
# validate a service ticket and request a proxy ticket (CAS v2.0)
my $r = $cas->service_validate( $server, $ticket, pgtUrl => $url );
if( $r->is_success ) {
print "User authenticated as: ", $r->user, "\n";
unless( defined $r->iou ) {
print "Service validation for proxying failed\n";
}
else {
print "Proxy granting ticket IOU: ", $r->iou, "\n";
...
# map IOU to proxy granting ticket via request to pgtUrl
...
$r = $cas->proxy( $pgt, $target_service );
if( $r->is_success ) {
print "Proxy ticket issued: ", $r->proxy_ticket, "\n";
}
}
}
like, slay. π
π DESCRIPTION π
Authen::CAS::Client hands you a simple interface for authenticating users with JA-SIG's CAS protocol. and bestie, both CAS v1.0 AND v2.0 are supported. we love range. π
π¦ METHODS π¦
new $url [, %args]
new() spins up a fresh instance of an Authen::CAS::Client object. $url is the CAS server's base URL. and %args? it may contain this optional parameter, okay:
fatal => $booleanβ if this one's true, the CAS client will literallydie()when an error happens, and$@will hold the error message. otherwise? you get anAuthen::CAS::Client::Response::Errorobject back instead. want the full tea on response objects? go see Authen::CAS::Client::Response. π«Ά
login_url $service [, %args]
login_url() gives you back the CAS server's login URL, which you can use to redirect users so they start the authentication process. $service is the service identifier that gets used during validation requests. %args may contain these optional parameters:
renew => $booleanβ this makes the CAS server force a user to re-authenticate even if an SSO session already exists for them. no shortcuts, bestie. π€gateway => $booleanβ this makes the CAS server only rely on SSO sessions for authentication. and if there's no SSO session for the current user? validation will result in a failure. π
logout_url [%args]
logout_url() returns the CAS server's logout URL, which you can use to redirect users so they end their authenticated sessions. bye babes. π %args may contain this optional parameter:
url => $urlβ if it's there, the CAS server will present the user with a link to the given URL once they've logged out. cute. π
validate $service, $ticket [, %args]
validate() tries to validate a service ticket using the CAS v1.0 protocol. $service is the service identifier that was passed to the CAS server during the login process. $ticket is the service ticket you received after a successful authentication attempt. it returns an appropriate Authen::CAS::Client::Response object. %args may contain this optional parameter:
renew => $booleanβ this makes the CAS server respond with a failure if the authentication validation was done via a CAS SSO session. π
service_validate $service, $ticket [, %args]
service_validate() tries to validate a service ticket using the CAS v2.0 protocol. it's similar to validate(), but it allows for greater flexibility when you need to proxy authentication to back-end services. the $service and $ticket parameters are the same as above. it returns an appropriate Authen::CAS::Client::Response object. %args may contain these optional parameters:
renew => $booleanβ this makes the CAS server respond with a failure if the authentication validation was done via a CAS SSO session.pgtUrl => $urlβ this tells the CAS server that a proxy ticket needs to be issued so authentication can be proxied to a back-end service.$urlis a callback URL that the CAS server will use to verify the service's identity. per the CAS specification, this URL must be HTTPS. and if this verification fails? normal validation still occurs, but a proxy granting ticket IOU will not be issued. π
also ngl, this call will block until the CAS server finishes its service verification attempt. the returned proxy granting ticket IOU can then be used to retrieve the proxy granting ticket that was passed as a parameter to the given URL. that's the whole loop, bestie. π
proxy_validate $service, $ticket [, %args]
proxy_validate() is almost identical in operation to service_validate() β except that both service tickets AND proxy tickets can be used for validation, and a list of proxies will be provided if proxied authentication has been used. the $service and $ticket parameters are the same as above. it returns an appropriate Authen::CAS::Client::Response object. %args may contain these optional parameters:
renew => $booleanβ this is the same as described above.pgtUrl => $urlβ this is the same as described above.
proxy $pgt, $target
proxy() is how you retrieve a proxy ticket that can be passed to a back-end service for proxied authentication. $pgt is the proxy granting ticket that was passed as a parameter to the pgtUrl you specified in either service_validate() or proxy_validate(). $target is the service identifier for the back-end system that will use the returned proxy ticket for validation. it returns an appropriate Authen::CAS::Client::Response object. π₯
π BUGS π
none are known at this time. but bestie, if you find one, please feel free to submit a report to the author. we're nice about it. π«Ά
π AUTHOR π
jason hord <pravus@cpan.org>
πΈ SEE ALSO πΈ
- Authen::CAS::Client::Response
- more info about CAS can be found at JA-SIG's CAS homepage:
<http://www.ja-sig.org/products/cas/>
π§ LICENSE π§
This software is information. It is subject only to local laws of physics. β¨ (genuinely iconic, no notes.)
and that's the whole page, bestie β straight from perl v5.36.0, dated 2022-10-13, living in section 3pm of the User Contributed Perl Documentation. read it, love it, authenticate responsibly. ππ¦πΈ
π¦ where this page comes from
- ubuntu noble: libauthen-cas-client-perl 0.08-2 Β· MIT
- ubuntu resolute: libauthen-cas-client-perl 0.08-2 Β· MIT
- ubuntu stonking: libauthen-cas-client-perl 0.08-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms