RegisterRegister    Log inLog in    SearchSearch   

Post new topic   Reply to topic
Goto page 1, 2  Next 
View previous topic :: View next topic  
Author Message
chumly



PostPosted: Thu Nov 30, 2006 11:06 am    Post subject: Generic external auth php script? Reply with quote

Hi All,

Anyone have a working example php script that could be used as a replacement for the phpbb auth.php system?

I want to intergrate our current db system, so I don't think installing a completely seperate forum system is ideal, and since we already have a database with the required information, all I need is a php script where I can tell it the host / db information.

Does anyone have such a generic script available?

Thanks!
Chumly
Back to top
View user's profile Send private message
adbot



PostPosted: Thu Mar 31, 2011 3:57 am 

Andrew
Mammoth


PostPosted: Thu Nov 30, 2006 11:33 am    Post subject: Reply with quote

Our example would be the one your after.

You don't need to install phpBB to see how it works - Just notice the queries and the data it returns to get an idea.
Back to top
View user's profile Send private message
chumly



PostPosted: Thu Nov 30, 2006 12:26 pm    Post subject: Reply with quote

Ah,

ok, this is making a little more sense now...
So your Auth.php that is in your example is what I'm looking for.
By changing the table / field names, then linking the gamecreate external auth setting to this script, I should be ready to go, right?

Thanks!
Chumly
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Thu Nov 30, 2006 1:16 pm    Post subject: Reply with quote

Yeah.

The example provided is a working example - it works if you have a phpBB database (as it uses phpbb table names etc).

You can just modify the calls appropriately.

For example, opening up auth.php (which is what you want to look at), find:

Quote:
// Include the database username, password, name and host to use here
$db =& new db('username', 'password', 'databasename', 'databasehost');

Modify these params to match your database.

Then for example if you see GetById:
Quote:
// Retrieve single user by unique ID callback
function GetById($id)
{
global $db;

$result = $db->query("SELECT user_id, username, user_email FROM phpbb_users WHERE user_id = %d", $id);
$row = $db->fetch_array($result);

if (!$row['user_id'])
return null;

return array( "GetByIdResult" => array("Id"=>$row['user_id'], "Name"=>$row['username'], "Nickname"=>$row['username'], "Username"=>$row['username'], "Email"=>$row['user_email']) );
}


This function returns:
* Id
* Name
* Nickname (deprecated)
* Username
* Email

You need to reply with the appropriate information for that user.

In phpBB, the 'user_id' column holds the unique user ID, your database may be different (ie just 'id' or something else). This must be a unique value that cannot ever change.

It's important to not remove any functionality from these calls.
Also notice:

if($row['user_id'])
return null;

This means return NULL (ie, no result) if the requested user id did not exist.

Be sure to not remove functionality from the methods.
Back to top
View user's profile Send private message
chumly



PostPosted: Thu Nov 30, 2006 5:32 pm    Post subject: Reply with quote

Now,
Does the use of the external auth system mean that any user returned with these function have access to the booking, or does gamecreate still use a list.

In otherwords... Do I need to filter these users to prevent them from being seen by gamecreate...

Thanks!
Chumly
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Thu Nov 30, 2006 5:59 pm    Post subject: Reply with quote

Not really sure what you mean?

If you use External authentication, ANY user permissions etc are tied to users your external users, it does NOT use GameCreate's internal users anymore, ever.
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 1:22 am    Post subject: Reply with quote

What I mean is that auth.php will return ANY registered user from phpbb, and as such any user who is registered at the web site has the ability to book a temporary server time.

So to prevent this, another field must be added to say if they can use it or not, then add the sql filter to auth.php to filter out non-authorised users.

Correct?
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 1:41 am    Post subject: Reply with quote

And the opposite it true for the other systems...

Permissions are still controlled by gamecreate, not the external auth system right?

So we still need to apply permissions to allow access to different servers / domains manually, rather than using our external DB.

Think you could look at adding a function to return a couple of permission flags from the external auth system?

One for booking, one for read only, one for write, one for full control, one for server id, one for domain id, and finally one for master control.

Any thing I might have missed here?
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 4:25 am    Post subject: Reply with quote

ok, One more hurdle..

I wish to insert the users name and ID into the GCPgae.php file
I'm using phpbb 2.0.20, and would like to just add the username and ID from the current user session data..

I would think it would be something like :

Code:
   $userinfo = array("__domainlogin__" => "bcbhosting",
               "__domainpassword__" => "PASSWORD",
               //"__externalid__" => 0,
               //"__externalname__" => 'GameCreate User');  $username
               "__externalid__" => $userdata['user_id'],
               "__externalname__" => $userdata['username']);


But this is not working.

It appears that when the GCPage.php get rendered, I lose this information.

Does anyone know what I would have to enter here to include the current users name and id# into this page?

Thanks!
Chumly
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Fri Dec 01, 2006 7:12 am    Post subject: Reply with quote

chumly wrote:
What I mean is that auth.php will return ANY registered user from phpbb, and as such any user who is registered at the web site has the ability to book a temporary server time.

So to prevent this, another field must be added to say if they can use it or not, then add the sql filter to auth.php to filter out non-authorised users.

Correct?

Pretty much yes.

auth.php (in the example) returns any users - If you simply return a null result for a user requested then GameCreate wont be aware of it.

However if you return a valid user, and then decide later to not return one - the user may still be logged into the website by their session.

Quote:
Permissions are still controlled by gamecreate, not the external auth system right?

Of course. You can just 'search' for users in the Permissions tab by email for example or username, and find users inside your database.

However we offer Web Services which allow some remote control of GameCreate so far.

Quote:
Think you could look at adding a function to return a couple of permission flags from the external auth system?


See http://doc.gamecreate.com/ManualWebService for documentation.

Also visit the 'Web Services' tab of your Domain (Top right link of GameCreate.com).

Specifically:
http://au.gamecreate.com/admin/Remote.asmx
http://au.gamecreate.com/admin/User.asmx (Not applicable if you are using external auth)

Or to control temporary servers, http://au.gamecreate.com/bookings/MakeBooking.asmx

(Note to use your domain URL, not specifically au.gamecreate.com).

Quote:

I would think it would be something like :

Code:
   $userinfo = array("__domainlogin__" => "bcbhosting",
               "__domainpassword__" => "PASSWORD",
               //"__externalid__" => 0,
               //"__externalname__" => 'GameCreate User');  $username
               "__externalid__" => $userdata['user_id'],
               "__externalname__" => $userdata['username']);


That's not valid php syntax.

You are editing an array (its just separated over multiple lines for clarity).

Change it to this:

Code:

$userinfo = array("__domainlogin__" => "bcbhosting",
               "__domainpassword__" => "PASSWORD",
               "__externalid__" => $userdata['user_id'],
               "__externalname__" => $userdata['username']);


Note: I have edited out your domain password from this and your post.
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 8:17 am    Post subject: Reply with quote

Hi Andrew,

I changed the code to match your example.
( which is what I started with.. )

And I'm getting the same error I was getting from the start.

Quote:

Sorry, an unknown error occurred preventing GameCreate from processing your request.
GameCreate administrators have been notified of this problem.

If you wish to create a Support Ticket about this problem,
please include this Error ID: UAXY-NFLS.


I verified this by replacing the GCPage.php with a fresh downloaded one, and changed the userinfo section. So, I'm still stuck with what is happening to the userinfo. It seems to be disappearing. The userinfo is fine up until the GC_RenderPage function is called. ( I had traced this earlier. ) This is with php 5.

Thanks
Chumly
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Fri Dec 01, 2006 8:24 am    Post subject: Reply with quote

I've checked our error logging system and you are not supplying a username and userid for that user.

Here's what your sending:

Request Variables:
__domainlogin__ = bcbhosting
__domainpassword__ = (removed)
__externalid__ =
__externalname__ =

id and name are blank.

Is $userdata defined?

Below the $userinfo = ... line, add:

print_r($userinfo);
die;

Which will just print out the contents of the array and end the page.

Get it so the externalid and name fields have values.
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 8:34 am    Post subject: Reply with quote

ok,
So I added that to the page, and ran it again...

Here is the output.

Array ( [__domainlogin__] => bcbhosting [__domainpassword__] => PASSWORD [__externalid__] => [__externalname__] => )

Notice that the username and password are empty.
This is what I'm talking about. I can trace their existance up to the point where I call 'require "GCPage.php";'

From that point on, it seems to wipe out my session data, and leave the $userdata array empty.
Back to top
View user's profile Send private message
chumly



PostPosted: Fri Dec 01, 2006 8:37 am    Post subject: Reply with quote

And, just for referrence, here is the page i'm using to call it.

Code:

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_POSTING);
init_userprefs($userdata);

//
// End session management
//

   define('SHOW_ONLINE', true);
   $page_title = $lang['Index'];
   include($phpbb_root_path . 'includes/page_header.'.$phpEx);

// Include our GCPage class
require "GCPage.php";

// Request the 'Edit' page from GameCreate Bookings (View, List, or Edit) pages are available
// See GCPage.php for runtime configuration information
GC_RenderPage('Edit');


include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
Back to top
View user's profile Send private message
Andrew
Mammoth


PostPosted: Fri Dec 01, 2006 8:39 am    Post subject: Reply with quote

Inside GCPage.php find:

Code:

function GC_RenderPage($name)
{


Add the line:
Code:
global $userdata;


So it looks like:

Code:
function GC_RenderPage($name)
{
   global $userdata;


Then your $userdata variable will be available from within that function and it will work.

Because at the moment the variable is not in scope to that function.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic All times are GMT + 10 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum powered by phpBB © 2001, 2005 phpBB Group
GameCreate Service Terms | Privacy Policy | © Copyright Mammoth Media 2001-2007
GameCreate™ is a trademark of Mammoth Media Pty Ltd. GameCreate® is a registered trademark in Australia.