Dancer2...Provider(3)
πΈ NAME πΈ
Dancer2::Plugin::Auth::Extensible::Role::Provider β the base role for authentication providers, bestie π
β¨ DESCRIPTION β¨
Okay so listen π β this is the base Moo::Role for authentication providers. It's the blueprint every provider role builds on, no cap.
It also throws in secure password matching for free π β and it automatically handles crypted passwords via Crypt::SaltedHash. Like, it just knows. Iconic behaviour, honestly.
π¦ ATTRIBUTES π¦
pluginβ the callingDancer2::Plugin::Auth::Extensibleobject. Required. You gotta have it, it's not optional, periodt πdisable_rolesβ defaults to the value of"disable_roles"inDancer2::Plugin::Auth::Extensible. So it just inherits the vibe from the main plugin, iykyk π«Άencryption_algorithmβ theencryption_algorithmused by"encrypt_password". Defaults to'SHA-512'β. That's the default, don't come for me.
π METHODS π
match_password $given, $correct
Matches the $given password against the $correct one. That's it, that's the whole job π.
encrypt_password $password
Encrypts the password $password using "encryption_algorithm" and hands you back the encrypted password. Slay π₯
π§ METHODS IMPLEMENTED BY PROVIDER π§
So here's the thing, bestie β the following methods must be implemented by the consuming provider class. The role doesn't do it for you, you have to bring them yourself π.
β required methods
authenticate_user $username, $passwordβ if either$usernameor$passwordis undefined, then die π. Return true on success. That's the whole contract.
π optional methods
These ones are optional but they extend the functionality of the provider β so like, you don't have to, but why wouldn't you π:
get_user_details $usernameβ die if$usernameis undefined. Otherwise return a user object (if that's appropriate for your backend) or a hash reference of user details πget_user_roles $usernameβ die if$usernameis undefined. Otherwise return an array reference of user roles πcreate_user %userβ create a user with the fields specified in%user.
The method should croak if the "username" key is empty or undefined π« . If a user with the specified username already exists, then we'd normally expect the method to die β though this is of course dependent on the backend in use, so like, ymmv depending on your setup.
The new user should be returned π«
get_user_by_code $codeβ try to find a user which has the"pw_reset_code"field set to$code. Returns the user on success βset_user_details $username, %updateβ update the user with$usernameaccording to%update.
Passing an empty or undefined $username should cause the method to die π.
The updated user should be returned.
set_user_password $username, $passwordβ set the password for the user specified by$usernameto$password, encrypted using"encrypt_password"β or via whatever other method is appropriate for the backend πpassword_expired $userβ the$usershould be as returned from"get_user_details". The method checks whether the user's password has expired and returns1if it has and0if it has not. Binary queen π
ngl this role is basically the group chat rules for auth providers β implement your methods, die when you're told to die, and everything's gonna be fine π
And that's the whole page, bestie π«Ά β brought to you by perl v5.42.0, dated 2026-08-25. Go forth and authenticate, you absolute icon ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Dancer2-Plugin-Auth-Extensible 0.714.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms