c++ user database integration

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
taekvideo
Registered User
Posts: 4
Joined: Tue Jun 16, 2009 4:22 pm
Location: Iowa, United States
Contact:

c++ user database integration

Post by taekvideo »

I couldn't find any existing library to do this so I coded it myself... this is meant for servers or multiplayer games written in c++ which want to use the phpbb3 user database to handle logins in their application... so that users can use the same account/password for the forums and the game/server and only have to register once.

It basically works like this:

Authenticator authenticator;
//initialize with mysql database information
authenticator.initialize("ip_address", "username", "password", "database_name", "table_prefix");
//call this function whenever a user is requesting to login to the game/server... the parameters are the username/password that the user sent to the game/server to login with. This function checks if the username/password are valid in the phpbb3 database.
if (authenticator.Authenticate("username", "password")){
//user's login information is valid
}
else{
//user's login information is invalid
}


I'm curious if there's any interest in this... and whether I should clean up the code and publish it (and where)... or if there's something similar that already exists.

taywyn
Registered User
Posts: 1
Joined: Wed Jul 08, 2009 8:15 pm

Re: c++ user database integration

Post by taywyn »

I'm interested in a C version of this and C++ is only a step away. If you put it up on the web somewhere, I'd like to see it (depending on license, actually. LGPL or weaker is preferred). Otherwise I'll be writing my own C auth code tonight.

taekvideo
Registered User
Posts: 4
Joined: Tue Jun 16, 2009 4:22 pm
Location: Iowa, United States
Contact:

Re: c++ user database integration

Post by taekvideo »

hmm, I subscribed to this topic so I could respond quickly but for some reason it didn't notify me until about 36 hours after you posted. Did you have to have a moderator approve your post like mine? That would explain it.

you can download the source code here: http://taekvideo.getmyip.com/downloads/ ... icator.zip

It wouldn't take too much to rewrite it for pure c... you'd have to use the Mysql C API instead of mysql++ (http://dev.mysql.com/doc/refman/5.0/en/c.html)
and of course rewrite my functions in C
If you'd like I could do it for you... probably by tomorrow. Unless of course you've already done it yourself.

this is the included readme:

Copyright (c) 2009, William M Brandt (aka 'Taekvideo')
All rights reserved.
Email: --removed (see included readme.txt)-- (feel free to contact me with any questions, concerns, or suggestions)

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistribution of any files containing source code covered by this license must retain the above copyright notice,
this list of conditions, and the following disclaimer.
* Neither the name William M Brandt nor the pseudonym 'Taekvideo' may be used to endorse or
promote products derived from this software without specific prior written permission.
* It's not required, but I would appreciate being included in your credits.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Read the comments contained in "authenticator.h" for more thorough documentation.
Basic usage:
1) Create an Authenticator object.
2) Call Authenticator::initialize()
3) Call Authenticator::authenticate() whenever you need to verify a username & password

example:

Authenticator authenticator;
authenticator.initialize("192.168.10.102", "taekvideo", "my password", "phpbb3", "phpbb_", 2);

string username, password;
cin >> username; //obviously you would get the username/password from the client over the network, not from cin
cin >> password;
int errorcode;
if (!authenticator.authenticate(username, password, errorcode)){
switch (errorCode){
...
}
}
else{
//username/password are valid
}


DEPENDENCIES:

md5 hashing code (included in download, written by L. Peter Deutsch - ghost@aladdin.com)
Mysql C API (libmysql.lib & libmysql.dll) - licensed under GPL (http://dev.mysql.com/downloads/connector/c/6.0.html)
Mysql++ (mysqlpp.lib & mysqlpp.dll) - licensed under LGPL (http://tangentsoft.net/mysql++/)

afraca
Registered User
Posts: 1
Joined: Sat Aug 29, 2009 9:51 am

Re: c++ user database integration

Post by afraca »

Could you please use another mirror or something for the .zip archive you just posted? Your server seems to be offline.

taekvideo
Registered User
Posts: 4
Joined: Tue Jun 16, 2009 4:22 pm
Location: Iowa, United States
Contact:

Re: c++ user database integration

Post by taekvideo »

afraca wrote:Could you please use another mirror or something for the .zip archive you just posted? Your server seems to be offline.
The server's up now so it should work.
If you have problems again use this: http://rapidshare.com/files/273662493/p ... icator.zip

taekvideo
Registered User
Posts: 4
Joined: Tue Jun 16, 2009 4:22 pm
Location: Iowa, United States
Contact:

Re: c++ user database integration

Post by taekvideo »

The links were broken.... I attached the source to this reply.
Attachments
phpbb3_authenticator.zip
(13.77 KiB) Downloaded 663 times

Post Reply