[SteemNova] SteemConnect v2 implementation

in #utopian-io7 years ago (edited)

image.png

One of SteemNova most important goals is Steem blockchain integration. The vision of authors is to restrict this game for Steemians only. This way we can control weekly SBD rewards to best players and maybe limit some multiaccounts in the future. Below article describes how SteemConnect login authentication has been implemented to SteemNova.

SteemConnect v2 API

SteemConnect requires special type of account to log in through. For its purposes @steemnova.app account has been created.

image.png

Official @steemnova.app third party authorization account

public static function getLoginUrl()
{
    return 'https://v2.steemconnect.com/oauth2/authorize?client_id=' . self::$CLIENT_ID . '&redirect_uri=' . HTTP_PATH.'index.php&scope=' . self::$SCOPE;
}

SteemConnect verification URL

Login and authentication

For the purposes of new authorization type, the Login Page has been refreshed.

image.png

Refreshed Login page

protected function login()
{
    $authstr = "authorization: " . $this->access_token;
    $check = curl_init();
    curl_setopt_array($check, array(
        CURLOPT_URL => "https://v2.steemconnect.com/api/me",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 1,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "{}",
        CURLOPT_HTTPHEADER => array(
            $authstr,
            "cache-control: no-cache",
            "content-type: application/json",
        ),
    ));
    $result = curl_exec($check);
    curl_close($check);
    $_result = json_decode($result);
    if(isset($_result->user)) {
        $this->data = $_result;
        return $_result->user;
    } else {
        return false;
    }
}

Core of authentication system

Additionally, admins can log in to Admin Panel through SteemConnect too!

Account registration

Classic login:password registration has been disabled. Old accounts can still login via password but in the future it will be turned off.
Steemians can register to game through SteemConnect. If they have no in game account yet, it will be created automatically. Just log in and voila!

if(empty($loginData))
    $authObj->register();
    ...

public function register()
{
    global $LNG;
    
    list($userId, $planetId) = PlayerUtil::createPlayer(
        Universe::current(),
        $this->scObj->getUser(),
        '',
        '',
        $LNG->getLanguage());
    
    return $userId;
}

Security

As account authentication needs only 'login' privilege (scope), only private MEMO key is needed to log in. Of course any private key can be used, but not needed.

image.png

SteemConnect v2 third party auth

image.png

SteemConnect button design-pack

Thanks to Andrej Cibík @andrejcibik, his SteemConnect button .css style has been used. It is imported from @noisy SteemConnect Design Pack repo

image.png

Andrej Cibík @andrejcibik SteemConnect logo pack

Screenshots

To prove successful authentication of user, his Steem avatar is drawn at the top of navigation bar.

image.png

Steem account avatar

Information

steemnova/steemnova project is fork of jkroepke/2Moons Open Source Browsergame Framework. The goal is to fix bugs and develop the engine in the direction of maximum Steem integration.

Links



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @vladimir-simovic, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

I'm not sure if you've seen that, but there is an SC2 PHP SDK created by @hernandev.

https://github.com/hernandev/sc2-sdk-php

Seems like we did the same job at the same time. I see his library much heavier, as I have implemented authentication call only.

@mys I did two packages on that front, one is the authentication part only also, a oauth2 by league provider:

https://github.com/hernandev/oauth2-sc2

But no matter what, good job, it's always nice to have more php implementations.

I'm working on a core steem library for PHP right now.

Already have half the wallet functionality working (brainkey, wif etc)

Also @mys, if you need to query Steem nodes for getting data on the RPC servers, you can use this one with PHP:

https://github.com/hernandev/light-rpc

Cheers

Will probably inject to SteemNova in the future too, thanks!

Hey everbody

My name is marsell and I am on Rank1 in Steemnova since a long time...

LET ME WARN YOU!!!

!!! DONT PLAY THIS SHIT GAME!!!!!

CHEATING ADMINS
BUGUSING ADMINS
LYING ADMINS
UNFAIR AND UNBALANCED

This is steemnova...

Logged in this morning using it.

steemnova-deanlogic_emp.png

Thank you @mys for all the work you do to improve the game day by day

Great work @mys, there is progress nearly every day.

Great work, thanks.

your the best mister
is the best

I love the new features of the game .. I love entering from #steemit to the game and have alternatives of real communication with the creators of the game .. THAT INTERACTION MAKES IT MORE FUN ... Thanks for the contributions to the #Steemnova community.

Coin Marketplace

STEEM 0.16
TRX 0.17
JST 0.029
BTC 69443.96
ETH 2493.44
USDT 1.00
SBD 2.54