Dancer2...Provider(3)

πŸ“¦ version 0.714.0, in opensuse-leap 16.0

🌸 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 calling Dancer2::Plugin::Auth::Extensible object. Required. You gotta have it, it's not optional, periodt πŸ’€
  • disable_roles β€” defaults to the value of "disable_roles" in Dancer2::Plugin::Auth::Extensible. So it just inherits the vibe from the main plugin, iykyk 🫢
  • encryption_algorithm β€” the encryption_algorithm used 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 $username or $password is 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 $username is 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 $username is 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 $username according 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 $username to $password, encrypted using "encrypt_password" β€” or via whatever other method is appropriate for the backend πŸ”
  • password_expired $user β€” the $user should be as returned from "get_user_details". The method checks whether the user's password has expired and returns 1 if it has and 0 if 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