1Rose::DB::Object::MakeMUestehrodCso:n:tPrgi(b3u)ted PerlRoDsoec:u:mDeBn:t:aOtbijoenct::MakeMethods::Pg(3)
2
3
4

NAME

6       Rose::DB::Object::MakeMethods::Pg - Create PostgreSQL-specific object
7       methods for Rose::DB::Object-derived objects.
8

SYNOPSIS

10         package MyDBObject;
11
12         our @ISA = qw(Rose::DB::Object);
13
14         use Rose::DB::Object::MakeMethods::Pg
15         (
16           chkpass =>
17           [
18             'password',
19             'secret' =>
20             {
21               encrypted_suffix => '_mangled',
22               cmp_suffix       => '_equals',
23             },
24           ],
25         );
26
27         ...
28
29         $o = MyDBObject->new(...);
30
31         $o->password('foobar');
32
33         # Something like: ":vOR7BujbRZSLM" (varies based on salt used)
34         print $o->password_encrypted;
35
36         print $o->password; # "foobar"
37         print "ok" if($o->password_is('foobar'); # "ok"
38
39         $o->secret('baz');
40
41         # Something like: ":jqROBZMqtWGJE" (varies based on salt used)
42         print $o->secret_mangled;
43
44         print $o->secret; # "baz"
45         print "ok" if($o->secret_equals('baz'); # "ok"
46

DESCRIPTION

48       "Rose::DB::Object::MakeMethods::Pg" creates methods that deal with data
49       types that are specific to the PostgreSQL database server.  It inherits
50       from Rose::Object::MakeMethods.  See the Rose::Object::MakeMethods
51       documentation to learn about the interface.  The method types provided
52       by this module are described below.
53
54       All method types defined by this module are designed to work with
55       objects that are subclasses of (or otherwise conform to the interface
56       of) Rose::DB::Object.  In particular, the object is expected to have a
57       "db" method that returns a Rose::DB-derived object.  See the
58       Rose::DB::Object documentation for more details.
59

METHODS TYPES

61       chkpass
62           Create a family methods for handling PostgreSQL's "CHKPASS" data
63           type.  This data type is not installed by default, but is included
64           in the standard PostgreSQL source code distribution (in the
65           "contrib" directory).  From the README file for CHKPASS:
66
67           "Chkpass is a password type that is automatically checked and
68           converted upon entry.  It is stored encrypted.  To compare, simply
69           compare against a clear text password and the comparison function
70           will encrypt it before comparing.
71
72           If you precede the string with a colon, the encryption and checking
73           are skipped so that you can enter existing passwords into the
74           field.
75
76           On output, a colon is prepended.  This makes it possible to dump
77           and reload passwords without re-encrypting them.  If you want the
78           password (encrypted) without the colon then use the raw() function.
79           This allows you to use the type with things like Apache's
80           Auth_PostgreSQL module."
81
82           This data type is very handy for storing encrypted values such as
83           passwords while still retaining the ability to perform SELECTs and
84           such using unencrypted values in comparisons.  For example, the
85           query
86
87               SELECT * FROM users WHERE password = 'foobar'
88
89           will actually find all the users whose passwords are "foobar", even
90           though all the passwords are encrypted in the database.
91
92           Options
93               "cmp_suffix"
94                   The string appended to the default method name to form the
95                   name of the comparison method.  Defaults to "_is".
96
97               "encrypted_suffix"
98                   The string appended to the default method name to form the
99                   name of the get/set method that handles the encrypted
100                   version of the CHKPASS value.  Defaults to "_encrypted".
101
102               "hash_key"
103                   The key inside the hash-based object to use for the storage
104                   of the unencrypted value.  Defaults to the name of the
105                   method.
106
107                   The encrypted value is stored in a hash key with the same
108                   name, but with "encrypted_suffix" appended.
109
110               "interface"
111                   Choose the interface.  The default is "get_set".
112
113           Interfaces
114               "get_set"
115                   Creates a family of methods for handling PostgreSQL's
116                   "CHKPASS" data type.  The methods are:
117
118                   "default"
119                       The get/set method for the unencrypted value.  (This
120                       method uses the default method name.)  If called with
121                       no arguments, the unencrypted value is returned, if it
122                       is known.  If not, undef is returned.
123
124                       If passed an argument that begins with ":", it is
125                       assumed to be an encrypted value and is stored as such.
126                       Undef is returned, since it is not feasible to
127                       determine the unencrypted value based on the encrypted
128                       value.
129
130                       If passed an argument that does not begin with ":", it
131                       is taken as the unencrypted value.  The value is
132                       encrypted using Perl's "crypt()" function paired with a
133                       randomly selected salt, and the unencrypted value is
134                       returned.
135
136                   "encrypted"
137                       The get/set method for the encrypted value.  The method
138                       name will be formed by concatenating the "default"
139                       method name (above) and the value of the
140                       "encrypted_suffix" option.
141
142                       If called with no arguments, the encrypted value is
143                       returned, if it is known.  If not, undef is returned.
144
145                       If passed an argument that begins with ":", it is
146                       assumed to be an encrypted value and is stored as such.
147                       The unencrypted value is set to undef, since it is not
148                       feasible to determine the unencrypted value based on
149                       the encrypted value.  The encrypted value is returned.
150
151                       If passed an argument that does not begin with ":", it
152                       is taken as the unencrypted value.  The value is
153                       encrypted using Perl's "crypt()" function paired with a
154                       randomly selected salt, and the encrypted value is
155                       returned.
156
157                   "comparison"
158                       This method compares its argument to the unencrypted
159                       value and returns true if the two values are identical
160                       (string comparison), false if they are not, and undef
161                       if both the encrypted and unencrypted values are
162                       undefined.
163
164           "get"
165               Creates an accessor method for PostgreSQL's "CHKPASS" data
166               type.  This method behaves like the "get_set" method, except
167               that the value cannot be set.
168
169           "set"
170               Creates a mutator method for PostgreSQL's "CHKPASS" data type.
171               This method behaves like the "get_set" method, except that a
172               fatal error will occur if no arguments are passed.
173
174           Example:
175
176               package MyDBObject;
177
178               our @ISA = qw(Rose::DB::Object);
179
180               use Rose::DB::Object::MakeMethods::Pg
181               (
182                 chkpass =>
183                 [
184                   'password',
185                   'get_password' => { interface => 'get', hash_key => 'password' },
186                   'set_password' => { interface => 'set', hash_key => 'password' },
187                   'secret' =>
188                   {
189                     encrypted_suffix => '_mangled',
190                     cmp_suffix       => '_equals',
191                   },
192                 ],
193               );
194
195               ...
196
197               $o = MyDBObject->new(...);
198
199               $o->set_password('blah');
200
201               $o->password('foobar');
202
203               # Something like: ":vOR7BujbRZSLM" (varies based on salt used)
204               print $o->password_encrypted;
205
206               print $o->get_password; # "foobar"
207               print $o->password;     # "foobar"
208               print "ok" if($o->password_is('foobar'); # "ok"
209
210               $o->secret('baz');
211
212               # Something like: ":jqROBZMqtWGJE" (varies based on salt used)
213               print $o->secret_mangled;
214
215               print $o->secret; # "baz"
216               print "ok" if($o->secret_equals('baz'); # "ok"
217

AUTHOR

219       John C. Siracusa (siracusa@gmail.com)
220

LICENSE

222       Copyright (c) 2010 by John C. Siracusa.  All rights reserved.  This
223       program is free software; you can redistribute it and/or modify it
224       under the same terms as Perl itself.
225
226
227
228perl v5.30.0                      2019-07-2R6ose::DB::Object::MakeMethods::Pg(3)
Impressum