xpaw/steam-openid

A correct and simple implementation of OpenID authentication for Steam

v3.1.0 2024-11-02 16:30 UTC

This package is auto-updated.

Last update: 2024-12-18 12:58:01 UTC


README

A very minimalistic OpenID implementation that hardcodes it for Steam only, as using a generic OpenID library may do unnecessary steps of “discovering” OpenID servers, which will end up leaking your origin server address, and worse, leave your website open to vulnerabilities of claiming wrong Steam profiles if the implementation is bugged.

The described problems are not theoretical, LightOpenID has been proven to have implementation problems, and even if you use validate and use regex on the final identity it can be spoofed and a third-party server can be used to pass the validation.

This library aims to avoid these problems by implementing the bare minimum functionality required for validating Steam OpenID requests against the hardcoded Steam server. This library only implements validation, you will need to implement Steam WebAPI calls yourself to fetch user profile information.

Before using this library, please read Valve's terms here.

Installation

composer require xpaw/steam-openid

See Example.php file for example usage.

Basic usage

use xPaw\Steam\SteamOpenID;

$SteamOpenID = new SteamOpenID( $ReturnToUrl );

if( $SteamOpenID->ShouldValidate() )
{
	try
	{
		$CommunityID = $SteamOpenID->Validate();
		echo 'Logged in as ' . $SteamID;
	}
	catch( Exception $e )
	{
		echo 'Login failed';
	}
}
else
{
	header( 'Location: ' . $SteamOpenID->GetAuthUrl() );
}

If you want to parse SteamIDs, take a look at SteamID.php.