Holger Rupprecht > Rose-DBx-Object-MakeMethods-EKSBlowfish-0.06 > Rose::DBx::Object::MakeMethods::EKSBlowfish

Download:
Rose-DBx-Object-MakeMethods-EKSBlowfish-0.06.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.06   Source  

NAME ^

Rose::DB::Object::MakeMethods::EKSBlowfish - Create Blowfish-specific object methods for Rose::DB::Object-derived objects.

VERSION ^

Version 0.06

SYNOPSIS ^

   package MyDBObject;

   our @ISA = qw(Rose::DB::Object);

   use Rose::DBx::Object::MakeMethods::EKSBlowfish(
   eksblowfish => 
      [
        'type' => 
        {
          cost      => 8,
          key_nul   => 0,
        },
      ],
   );

  ...

  $o = MyDBObject->new(...);

  $o->password('foobar');

  # Something like: "$2$08$NWgpob52QKA2fRUgCwB93O1qoHZGu/Kr9iGfI/2nhy9uc9R2IG9by"
  print $o->password_encrypted;

  print $o->password; # "foobar"
  print "ok" if($o->password_is('foobar'); # "ok"

DESCRIPTION ^

Rose::DB::Object::MakeMethods::EKSBlowfish creates methods that deal with eksblowfish encrypted passwords. It inherits from Rose::Object::MakeMethods. See the Rose::Object::MakeMethods documentation to learn about the interface. The method types provided by this module are described below.

All method types defined by this module are designed to work with objects that are subclasses of (or otherwise conform to the interface of) Rose::DB::Object. In particular, the object is expected to have a db method that returns a Rose::DB-derived object. See the Rose::DB::Object documentation for more details.

METHODS TYPES ^

eksblowfish

Create a family methods for handling eksblowfish encrypted passwords.

Options
cmp_suffix

The string appended to the default method name to form the name of the comparison method. Defaults to "_is".

encrypted_suffix

The string appended to the default method name to form the name of the get/set method that handles the encrypted version of the CHKPASS value. Defaults to "_encrypted".

hash_key

The key inside the hash-based object to use for the storage of the unencrypted value. Defaults to the name of the method.

The encrypted value is stored in a hash key with the same name, but with encrypted_suffix appended.

Interfaces
get_set

Creates a family of methods for handling eksblowfish encrypted passwords. The methods are:

default

The get/set method for the unencrypted value. (This method uses the default method name.) If called with no arguments, the unencrypted value is returned, if it is known. If not, undef is returned.

If passed an argument that begins with bcrypt identifier, it is assumed to be an encrypted value and is stored as such. Undef is returned, since it is not feasible to determine the unencrypted value based on the encrypted value.

If passed an argument that does not begin with bcrypt identifier, it is taken as the unencrypted value.

encrypted

The get/set method for the encrypted value. The method name will be formed by concatenating the default method name (above) and the value of the encrypted_suffix option.

If called with no arguments, the encrypted value is returned, if it is known. If not, undef is returned.

If passed an argument that begins with bcrypt identifier, it is assumed to be an encrypted value and is stored as such. The unencrypted value is set to undef, since it is not feasible to determine the unencrypted value based on the encrypted value. The encrypted value is returned.

If passed an argument that does not begin with bcrypt identifier, it is taken as the unencrypted value. =item comparison

This method compares its argument to the unencrypted value and returns true if the two values are identical (string comparison), false if they are not, and undef if both the encrypted and unencrypted values are undefined.

Example:

    package MyDBObject;

    use base qw(Rose::DB::Object);
    use Rose::DBx::Object::MakeMethods::EKSBlowfish(
    eksblowfish => 
       [
         'type' => 
         {
           cost      => 8,
           key_nul   => 0,
         },
       ],
    );:w

    
    __PACKAGE__->meta->setup(
        db => $db,
        table => 'users',
    
        columns => [
            id              => { type => 'serial',    not_null => 1 },
            name            => { type => 'varchar',   length   => 255, not_null => 1 },
            password        => { type => 'eksblowfish', not_null => 1, },
        ],
    
        primary_key_columns => ['id'],
    
        unique_key => ['name'],
    
    );

    ...

    $o = MyDBObject->new(...);

    $o->password('blah');

    $o->password('foobar');

    # Something like: "$2$08$ft6IhGIrQz1uDJiv6nD7sePuQEfcpb7excBQnDGu2GmDuk7kb5Ie6"
    print $o->password_encrypted;

    print $o->get_password; # "foobar"
    print $o->password;     # "foobar"
    print "ok" if($o->password_is('foobar'); # "ok"
_encrypted

the encryption generator

AUTHOR ^

Holger Rupprecht (holger.rupprecht@gmx.de)

LICENSE ^

Copyright (c) 2013 by Holger Rupprecht. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1; # End of Rose::DBx::Object::MakeMethods::EKSBlowfish

syntax highlighting: