Giter Site home page Giter Site logo

steam-auth's Introduction

Steam authentication and User Details

Latest Stable Version Total Downloads License GitHub issues Packagist

This package enables you to easily log users in via Steam and get user details , using their OpenID service. However, this package does not require that you have the OpenID PHP module installed!

Installation Via Composer

Add this to your composer.json file, in the require object:

"vikas5914/steam-auth": "1.*"

After that, run composer install to install the package.

OR

composer require vikas5914/steam-auth:1.*

Usage example

require __DIR__ . '/vendor/autoload.php';

$config = array(
    'apikey' => 'xxxxxxxxxxxxxxxxx', // Steam API KEY
    'domainname' => 'http://localhost:3000', // Displayed domain in the login-screen
    'loginpage' => 'http://localhost:3000/index.php', // Returns to last page if not set
    "logoutpage" => "",
    "skipAPI" => false, // true = dont get the data from steam, just return the steamid64
);

$steam = new Vikas5914\SteamAuth($config);

if ($steam->loggedIn()) {
    echo "Hello " . $steam->personaname . "!";
    echo "<a href='" . $steam->logout() . "'>Logout</a>";
} else {
    echo "<a href='" . $steam->loginUrl() . "'>Login</a>";
}

User-Data is accessible through $steam->varName; You can find a basic list of variables in the demo file or a more advanced one in the code.

Check if the user is logged in with $steam->loggedIn(); (Will return true or false)

Planned

  1. Test Case
  2. Better ReadMe

Legal stuff

If you choose to use the steam web-api you need to follow the Steam Web API Terms of Use found at http://steamcommunity.com/dev/apiterms

The marked code is taken from Syntax_Error's "Ultra Simple Steam-Login" Class found at http://forums.steampowered.com/forums/showthread.php?t=1430511

forthebadge

steam-auth's People

Contributors

linkjay avatar vikas5914 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

steam-auth's Issues

Logging out after login/refresh

In the usage example the $steam->logout() function is called which logs out the user after login. I think this is what issue #5 is refering to.

echo "<a href='" . $steam->logout() . "'>Logout</a>";

This is my modified example if anyone has issues like #5:

<?php
session_start();
require __DIR__ . '/vendor/autoload.php';

$config = array(
    'apikey' => 'xxxxxxxxxxxxxxxxx', // Steam API KEY https://steamcommunity.com/dev/apikey
    'domainname' => 'http://localhost:3000', // Displayed domain in the login-screen
    'loginpage' => 'http://localhost:3000/index.php', // Returns to last page if not set
    "logoutpage" => "",
    "skipAPI" => false, // true = dont get the data from steam, just return the steamid64
);

$steam = new Vikas5914\SteamAuth($config);

if(isset($_GET['logout'])){
    $steam->logout();
    echo'Logged out...<br/>';
}

if ($steam->loggedIn()) {
    echo "Hello " . $steam->personaname . "! ";
    echo "<a href='?logout'>Logout</a>";
} else {
    echo "<a href='" . $steam->loginUrl() . "'>Login</a>";
}

echo $steam->debug();
?>

getaddrinfo failed

Getting this below error while testing

file_get_contents(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known

Steamid validation failure

On line 134 of src/SteamAuth.php, $result is now always an empty string due to the requested resource now returning 403 as described by the PHP warning:

file_get_contents(https://steamcommunity.com/openid/login): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden

Because of this, the validate() function never returns a steamid, and login validation always fails.

This came to my attention about 5 days ago when I was getting messages that registration on my site stopped working. This issue entirely prevents this script from working, for everyone.

get_magic_quotes_gpc has been deprecated as of PHP 7.4.0, and removed as of PHP 8.0.0

I encountered a problem caused by the absence of the get_magic_quotes_gpc function in PHP 8.

From PHP.net on the function spec page:

This function has been DEPRECATED as of PHP 7.4.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.

Seems that the function can be removed from the code without particolar problems: PHP 7.4 deprecated get_magic_quotes_gpc function alternative (Stack Overflow).

For others using the lastest release (v1.0.2) with PHP 8+, a workaround can be adding this code:

//Fix "get_magic_quotes_gpc" in PHP 8+.
if(!function_exists('get_magic_quotes_gpc')) {
  function get_magic_quotes_gpc() { return false; }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.