Page 1 of 1

Authenticate User against different Database

PostPosted: Fri Mar 02, 2012 4:49 pm
by JGerrity
Hello,

I've read the posts and docs about authentication but can't seem to find something applicable.

When a user logs in (I'm actually using the WebAuction app), I would like the authentication to happen against a different DB than that of the WebAuction App. I know it makes more sense to use the same DB and WebAuction has it's own tables for users, etc.. however, our site admin has already setup a DB for user authentication and I'd like to authenticate against that. So, the webauction app would actually be using two databases...would it make more sense to pass the loing portion over to a different app and then pass back a value to indicate authenticated or not...(logged in to bid).

Thank you,
Jason

Re: Authenticate User against different Database

PostPosted: Fri Mar 02, 2012 6:12 pm
by shannah
If the db is on the same server and dbms, you could just create a view to the target database and use that view as your users table.
e.g.
Code: Select all
create view users as select * from otherdb.users

Re: Authenticate User against different Database

PostPosted: Sat Mar 03, 2012 7:49 am
by JGerrity
Hi Steve,

Thanks for the quick reply.

My mistake in not stating that I'm a complete noob when it comes to coding.... could you please translate your response into english ? ;)

Where am I creating this view and putting that code?

Cheers,
J.

Re: Authenticate User against different Database

PostPosted: Sat Mar 03, 2012 2:36 pm
by ADobkin
I've never tried this, but based on Steve's response, I would create a view in the MySQL database that contains your application tables. You would do this either using the MySQL command line (if you are familiar with it) or a GUI such as phpMyAdmin or MySQL Workbench.

Once the view has been created, you would specify this view name (called "users" in Steve's example) in the conf.ini folder as your new users table, e.g.:

Code: Select all
[_auth]
users_table = "users"

Re: Authenticate User against different Database

PostPosted: Wed Mar 14, 2012 5:47 am
by JGerrity
Just wanted to say thank you for the response.

It worked!

Regards,
J.