<<

NAME

Koha::Token - Tokenizer

SYNOPSIS

    use Koha::Token;
    my $tokenizer = Koha::Token->new;
    my $token = $tokenizer->generate({ length => 20 });

    # safely generate a CSRF token (nonblocking)
    my $csrf_token = $tokenizer->generate({
        type => 'CSRF', id => $id, secret => $secret,
    });

    # or check a CSRF token
    my $result = $tokenizer->check_csrf({
        id => $id, secret => $secret, token => $token,
    });

DESCRIPTION

    Designed for providing general tokens.
    Created due to the need for a nonblocking call to Bytes::Random::Secure
    when generating a CSRF token.

METHODS

new

    Create object (via Class::Accessor).

generate

    my $token = $tokenizer->generate({ length => 20 });
    my $csrf_token = $tokenizer->generate({
        type => 'CSRF', id => $id, secret => $secret,
    });

    Generate several types of tokens. Now includes CSRF.
    Room for future extension.

generate_csrf

    Shortcut for: generate({ type => 'CSRF', ... })

check

    my $result = $tokenizer->check({
        type => 'CSRF', id => $id, secret => $secret, token => $token,
    });

    Check several types of tokens. Now includes CSRF.
    Room for future extension.

check_csrf

    Shortcut for: check({ type => 'CSRF', ... })

AUTHOR

    Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands

<<