[REQUEST] Login with STEAM

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

[REQUEST] Login with STEAM

Post by Arnevb »

Hello Stoker and other developers,

I'd like to have the Steam API Installed on my forum. It would be such an improvement if my users can just sign in with their Steam Account. Since the openID plugin is autdated, i need someone who wants to install it on my site. The code that should be integrated is:

Code: Select all

<?php
/**
*
* @package Steam Community API
* @copyright (c) 2010 ichimonai.com
* @license http://opensource.org/licenses/mit-license.php The MIT License
*
*/

class SteamSignIn
{
	const STEAM_LOGIN = 'https://steamcommunity.com/openid/login';

	/**
	* Get the URL to sign into steam
	*
	* @param mixed returnTo URI to tell steam where to return, MUST BE THE FULL URI WITH THE PROTOCOL
	* @param bool useAmp Use & in the URL, true; or just &, false. 
	* @return string The string to go in the URL
	*/
	public static function genUrl($returnTo = false, $useAmp = true)
	{
		$returnTo = (!$returnTo) ? (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] : $returnTo;
		
		$params = array(
			'openid.ns'			=> 'http://specs.openid.net/auth/2.0',
			'openid.mode'		=> 'checkid_setup',
			'openid.return_to'	=> $returnTo,
			'openid.realm'		=> (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'],
			'openid.identity'	=> 'http://specs.openid.net/auth/2.0/identifier_select',
			'openid.claimed_id'	=> 'http://specs.openid.net/auth/2.0/identifier_select',
		);
		
		$sep = ($useAmp) ? '&' : '&';
		return self::STEAM_LOGIN . '?' . http_build_query($params, '', $sep);
	}
	
	/**
	* Validate the incoming data
	*
	* @return string Returns the SteamID64 if successful or empty string on failure
	*/
	public static function validate()
	{
		// Star off with some basic params
		$params = array(
			'openid.assoc_handle'	=> $_GET['openid_assoc_handle'],
			'openid.signed'			=> $_GET['openid_signed'],
			'openid.sig'			=> $_GET['openid_sig'],
			'openid.ns'				=> 'http://specs.openid.net/auth/2.0',
		);
		
		// Get all the params that were sent back and resend them for validation
		$signed = explode(',', $_GET['openid_signed']);
		foreach($signed as $item)
		{
			$val = $_GET['openid_' . str_replace('.', '_', $item)];
			$params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($val) : $val; 
		}

		// Finally, add the all important mode. 
		$params['openid.mode'] = 'check_authentication';
		
		// Stored to send a Content-Length header
		$data =  http_build_query($params);
		$context = stream_context_create(array(
			'http' => array(
				'method'  => 'POST',
				'header'  => 
					"Accept-language: en\r\n".
					"Content-type: application/x-www-form-urlencoded\r\n" .
					"Content-Length: " . strlen($data) . "\r\n",
				'content' => $data,
			),
		));

		$result = file_get_contents(self::STEAM_LOGIN, false, $context);
		
		// Validate wheather it's true and if we have a good ID
		preg_match("#^http://steamcommunity.com/openid/id/([0-9]{17,25})#", $_GET['openid_claimed_id'], $matches);
		$steamID64 = is_numeric($matches[1]) ? $matches[1] : 0;

		// Return our final value
		return preg_match("#is_valid\s*:\s*true#i", $result) == 1 ? $steamID64 : '';
	}
}
I have completely no idea how to do this, but it seems to be pretty easy. This is just an easy version of the script (wich works), but Steam is also providing a very detailed version of it (wich can be found here: http://developer.valvesoftware.com/wiki ... 28v0001.29). I also browsed the openID website, but again, the phpbb code is outdated.

So, if anyone of you has an idea how to do this, and wants to help me with this, that would be great! If you want, I can pay for it (as long as it's not a fortune xD).

Arne

[REQUEST] Login with STEAM

Post by Arnevb »

Does anyone know something about this? :s

[REQUEST] Login with STEAM

Post by Stoker »

Try the Mod request forum at phpbb.com or maybe the Steam community.

[REQUEST] Login with STEAM

Post by martin123456 »

There has been lots of posts wanting facebook /windows msn / twitter / and many more requests and to put it clear

None of the mods made work for long

this one http://www.phpbb.com/community/viewtopi ... &t=1883675 seems to be the longest working one and it works well

why not contact the creator before the mod gets finished and released ?

its your best bet ;)

[REQUEST] Login with STEAM

Post by Arnevb »

:? Indeed, I can only try it.