Best Practice MySQL and storing password to another ODBC database

Hi All,

Have a question regarding how best to store an ODBC password for a different database/server in MySQL.  Currently I have an Oracle Database for our Districts student information system.  

I am developing a simplex Perl Program for the Web where Parents will be able to enter in their unique user/password for their student (which I will store in a MySQL Database) and then the Perl program will initiate an ODBC connection to the Oracle student database to prepopulate form data on name, address, dob, etc. that is already in the Oracle system to generate the multitude of Registration forms we have that parents hate filling out because much of the form data across the different forms is redundant.

The goal is for them to enter their user/pass into the system, the system pull data from the Oracle database and put into a simple web form,  modify any data that needs to be and save this new information into a MySQL database and the parents simply print off the forms they modified to bring in during our registration in the fall.

My problem is this.  I can create a MySQL database and create each user for parents, but how SHOULD I store the ODBC password for the Oracle Database which is the keys to the kingdom for reading ALL data in the oracle database?

If I store the Oracle ODBC password in a table in MySQL for the perl program to use to initiate a remote connection to pull data, then any authorized user could in essence remotely connect to the MySQL database and read that password using a command prompt with a simple select statement.  While I know our parents or students won't know how to do that, I would rather not chance it.

Is their a way to specify a specific table that only the local host can read from that table, IE a Perl Script on the server executes the select statement to get the password and is then is used to initiate another ODBC connection to Oracle using the info from that table?
Who is Participating?
gr8gonzoConnect With a Mentor ConsultantCommented:
All that said, that much security is usually overkill. Unless you're dealing with untrustworthy developers and sensitive data, I would just store the credentials in a file outside the web root, use code to read the credentials in as necessary, and connect directly to the Oracle DB from Perl and do the work.

It all depends on your situation.
Tomas Helgi JohannssonCommented:

There are several ways to do this.
You can store the username and passw using encryption, SHA or MD5 however there are downside on using just one of the methods. Best way is to combine the methods like it is shown in this blog
and here

Hope this helps.

    Tomas Helgi
You should not add direct access from this perl to the oracle DB.  Your perl should use an intermediary connection to a "service page" this way you can maintain security of the Oracle instance while limiting the exposure.

Given you already have login access, which presumably has access mask where each user is granted ......
Is adding a mask that will apply to the parents requires complex modification?
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Just some feedback on Tomas's comment - you cannot store the password using hashes like SHA or MD5. Hashes are meant to validate incoming passwords, they cannot be "decrypted", so to speak.

I would not store the password in a database table unless every user has his/her own connection to the Oracle database. Typically, you have a single set of credentials, so there's no real sense to use a database table to store a single record.

When it all comes down, it's going to be difficult to prevent authorized users (those who have access to the filesystem and database) from being able to access the password. You can certainly encrypt it, but the encryption key typically will need to be readable by the script, which means it will be visible to such authorized users.

You -can- limit a user to specific actions on a specific MySQL table:

GRANT SELECT  ON TABLE `database`.`table` TO 'username'@'hostname';

...but an authorized user could use your main connection to query the table.

If you're trying to ensure that local developers and authorized users cannot access the Oracle instance, then the best way is to use arnold's approach in conjunction with a public/private key pair to encrypt the requests, since a separate page would likely mean a separate server (and in turn, a separate filesystem):

1. Server A uses a public key to encrypt a formatted request and sends it to Server B.
2. Server B uses its private key to decrypt the message and run the query against the Oracle DB.
3. Server B formats the response from the Oracle DB into something transmittable (e.g. XML), and returns that response to the initial request.

In this manner, developers on Server A will have their normal access, but they won't be able to see what's happening on Server B, or have access to its filesystem and private key.
NoodlesWIUAuthor Commented:
Lots of interesting posts!  I have to say security is relative.  For my situation, I have already salted user/passes for individual users to the MySQL database for authentication.  My problem is how do I use the server to act as a proxy so to speak to say "oh, you've authenticated to my database, now let me use my secret password for the other database to tell server B I'm going to pull specific info for the user who just authenticated to me."

I don't want to store it in a table that the users could theoretically query because it would have to be plain text for the script to query the MySQL record to provide that as the password for the connection to the other database.

But if I can store that password in a text file outside the web directory where only the system could read it, that would be fine for my application and be considered sufficiently secured in my book.

I say security is relative because if my database was storing data in respects to the mating habits of bunnies I could use plain text all day because that info has no real value to anyone else.

But because our master database stores names, addresses, DOB and phone numbers, that would only be used by grade school students parents, I'd like to er on the side of reasonable caution.  I've done that by salting the user passwords, and storing the password on the system outside a directory that the rest of the world can't see but the system can sounds like a "secure enough" solution.

I'm open for feedback on this.  If I'm absolutely nuts please tell me.  I'm here to learn and looking to you guys for some guidance.  =)
Why not let the Oracle side periodically access the mysql database as a linked server and draw data in/populate responses.
Async versus syncrounous setup.

Parent interacts with mysql creates a request.
SP on ORACLE queries/process prior approved tasks. Gathers prior approved data. updates the mysql database.

This way security is maintained.

oracle can have MYSQL as a linked server.  You possibly can do the reverse using ODBCTAB, but I believe that will/could potentially expose/compromise your security.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.