/usr/share/doc/libapache2-mod-auth-pubtkt/examples/perl-login/test_pubtkt.pl is in libapache2-mod-auth-pubtkt 0.11-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #!/usr/bin/env perl
=pod
Perl implementation of mod_auth_pubtkt ticket generateion.
see https://neon1.net/mod_auth_pubtkt/ for more details.
Copyright (C) 2012 A. Gordon ( gordon at cshl dot edu )
LICENSE: Apacle License (see LICENSE file)
See README.perl.md file for more details.
=cut
use strict;
use warnings;
use mod_auth_pubtkt;
##
## Generate a ticket
##
my $ticket = pubtkt_generate(
privatekey => "key.priv.pem",
keytype => "rsa",
digest => undef,
clientip => undef,
userid => "102",
validuntil => time() + 86400,
graceperiod=> 3600,
tokens => undef,
userdata => undef);
print $ticket,"\n";
##
## Verify the same ticket
##
my $ok = pubtkt_verify (
publickey => "key.pub.pem",
keytype => "rsa",
digest => undef,
ticket => $ticket
);
die "Ticket verification failed.\n" if not $ok;
##
## Change something in the ticket, then verify again (which should fail)
##
$ticket =~ s/uid=102/uid=103/;
$ok = pubtkt_verify (
publickey => "key.pub.pem",
keytype => "rsa",
digest => undef,
ticket => $ticket
);
die "Error: forged ticket verified successfully, something is terribly wrong." if $ok;
print "all ok\n";
|