HTML::...stToken(3pm)

πŸ“¦
version 2.04 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– HTML::...stToken(3pm) β€” User Contributed Perl Documentation πŸ’–

okay bestie, sit down, hydrate, because we're talking about HTML::FormFu::Element::RequestToken and it's honestly iconic. this is the perl doc page for it, straight from the user-contributed perl documentation, and i'm gonna walk you through every single crumb. no skipping. periodt.


✨ VERSION ✨

version 2.04 β€” that's the one, that's the era we're living in. πŸ’…


✨ SYNOPSIS ✨

the little taste test, the vibe check, the "here's how you'd actually use it":

my $e = $form->element( { type => 'Token' } );

my $p = $form->element( { plugin => 'Token' } );

see? two ways in. one as an element (type => 'Token'), one as a plugin (plugin => 'Token'). pick your fighter 🫢


✨ DESCRIPTION ✨

okay so this field? it's a bouncer. πŸšͺ a little bodyguard for your form. it can prevent CSRF attacks, which is a whole category of "someone else is pretending to be you and submitting your forms" nonsense.

how does it do it? it holds a random token. and then, after the form gets submitted, that token gets checked against the token that's stored in the session of the current user. if they match, you're in. if they don't β€” nope, not today. πŸ™ˆ

and if you want a convenient way to actually wire this up, go look at "request_token_enable" in Catalyst::Controller::HTML::FormFu. it makes the whole thing way less annoying, iykyk. 🌸


✨ NAME ✨

HTML::FormFu::Element::RequestToken β€” a hidden text field which contains a unique token. that's the whole elevator pitch. short, sweet, slays. ✨


✨ ATTRIBUTES ✨

πŸŽ€ context

this is the value of the stash key for the Catalyst context object β€” you know, the $c. defaults to "context".

πŸŽ€ expiration_time

time to life for a token, in seconds. yes, "time to life," that's what the original says, we don't rewrite the lore. defaults to 3600.

πŸŽ€ session_key

the session key used to store the tokens. defaults to "__token". πŸ‘‘

πŸŽ€ limit

caps how many tokens get kept in the session. defaults to 20. like a guest list, but for tokens.

πŸŽ€ constraints

defaults to HTML::FormFu::Constraint::RequestToken and HTML::FormFu::Constraint::Required. two of them. a duo. a dynamic. πŸ’œ

πŸŽ€ message

sets the error message. that's it, that's the whole description. your words, your vibe. πŸ’…


✨ METHODS ✨

🌈 expire_token

this method looks in the session for expired tokens and removes them. it's giving spring cleaning. it's giving blocking-and-deleting. 🧹

🌈 get_token

generates a new token and stores it in the stash. brand new token, fresh out the oven. πŸ“

🌈 verify_token

checks whether a given token is already in the session. returns 1 if it exists, 0 otherwise. yes/no, in/out, iconic binary energy. ✨


✨ SEE ALSO ✨

go read these next, they're the friend group:

  • Catalyst::Controller::HTML::FormFu
  • HTML::FormFu::Plugin::RequestToken
  • HTML::FormFu::Constraint::RequestToken
  • HTML::FormFu

✨ AUTHOR ✨

Moritz Onken, "onken@houseofdesign.de" β€” thank you for your service 🫑


✨ LICENSE ✨

this library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. so like. go off. πŸ’–


✨ AUTHORS ✨

  • Carl Franks <cpan@fireartist.com>
  • Nigel Metheringham <nigelm@cpan.org>
  • Dean Hamstead <dean@bytefoundry.com.au>

the trio. the main characters. πŸ‘‘


this software is copyright (c) 2007-2018 by Carl Franks / Nigel Metheringham / Dean Hamstead.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


aaaand that's the whole page bestie, no cap, every crumb accounted for. πŸ’€βœ¨

perl v5.36.0 Β· 2022-12-06 β€” that's the source and the date, mwah, and this doc for HTML::...stToken(3pm) is officially done. slay, go build something safe, drink water, ily πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from