DBIx-MyPassword
view release on metacpan or search on metacpan
protected password file and still get the benefits of using aliases.
Keeping all of your password information in one place has many benefits.
For one, if you have a security policy that forces you to periodically
change your database password, you only have to make the change in one
place to change it for all of your scripts. Also, with all of your
passwords in one spot, you can make sure that the security on your
password file is tight.
Password File Contents
This module assumes that all of your database connection information is
stored in a standard CSV file. This file (or files) can have as many
records as you would like. The fields found in each record include:
1 Alias
The only non-connection field, this is the alias that you will use
to reference the connection information
2 User
The database user
3 Password
The password for the database user
5 Data Source
A DBI data source, for instance "dbi:mysql:test"
6 Options
DBI options that will be eval'ed into a hash, for instance
"RaiseError=>1,PrintError=>1"
Specifying The Password File Location
Currently, there are four places that this module searches for your
password file. The order of the search is:
1 Explicit File Via use
File specified in when 'use'ing the module
2 Explicit File Via Environment
File specified by the MYPASSWORD environment variable
3 Current Working Directory
A file named '.mypassword' in the current working directory
4 Home Directory
A file named '.mypassword' in the users home directory, as specified
by the HOME environment variable
Securing The Password File
One of the primary reasons that this module was developed was so that I
could secure my password information in a shared environment. Here is
how I do it. If you see holes in this, please let me know. Also, I do
most of my development on some flavor of UNIX, Linux, AIX, etc. These
systems are what I know best. If there is a better (or just plain
different) way to do security on another system, let me know and I'll
include it here.
For *X, all that you have to do is change the permissions on your
password file so that you are the only person who can read it. A simple:
chmod 400 .mypassword
is all that it takes. Each user can have their own password file that
only they can read. The caveat of this is that only scripts executed by
you can read the file too... not sure how that fairs for web
development.
SUBROUTINE DETAILS
connect(virtual_user)
An override of the of the DBI::connect subroutine. This method looks up
the specified virtual user and returns a standard DBI connection.
getVirtualUsers()
Return a sorted list of virtual users.
checkVirtualUser(virtual_user)
Returns true if the specified virtual user exists, false if not.
getUser(virtual_user)
Return database user for the specified virtual user.
getPassword(virtual_user)
Return password for the specified virtual user.
getDataSource(virtual_user)
Return data source information for the specified virtual user.
getOptions(virtual_user)
Return options for the specified virtual user.
INSTALL
Just a standard module install will get the job done. If you would like,
you can set the environment variables MP_DBUSER, MP_DBPASS, MP_DBDS, and
MP_DBOPTS to allow the test scripts to connect to a real database.
MP_DBUSER -> A real database user name
MP_DBPASS -> The database user's password
MP_DBDS -> A DBI data source, for instance "dbi:mysql:test"
MP_DBOPTS -> Any DBI connection options, for instance "RaiseError => 1, PrintError => 1"
Environment variables are not, these are the commands to install:
perl Makefile.PL
make
make test
make install
AUTHOR
Josh McAdams, joshua.mcadams at gmail dot com
SEE ALSO
perl(1); DBI(3); DBIx::Password(3);
( run in 0.480 second using v1.01-cache-2.11-cpan-99c4e6809bf )