invisnik / laravel-steam-auth

Laravel Steam Auth
MIT License
172 stars 67 forks source link

Strange validation failure. Request is not valid. #31

Closed sanny-io closed 8 years ago

sanny-io commented 8 years ago

I'm working with a local project and a clone of the project on my web server. The two are identical with the exception of the .env file and such. This package works flawlessly on my local project, but seems to run into issues on the remote project.

config/steam-auth.php

'redirect_url' => '/login',

routes.php

Route::get('login', 'AuthController@login');

The AuthController's login function is pretty much identical to the example on the git in terms of core functionality.

public function login()
    {
        if ($this->steam->validate()) {
            $info = $this->steam->getUserInfo();
            if (!is_null($info)) {
                $user = User::where('steam_id', $info->getSteamID64())->first();

                if (is_null($user)) {
                    $user = User::create([
                        'steam_id'  => $info->getSteamID64(),
                        'username' => $info->getNick(),
                        'avatar'   => $info->getProfilePictureFull(),                
                    ]);

                    $user->ip_address = Request::ip();
                    $user->save();
                } else {
                    $user->ip_address = Request::ip();
                    $user->update([
                        'username' => $info->getNick(),
                        'avatar'   => $info->getProfilePictureFull(),
                    ]);
                }

                Auth::login($user, true);

                return redirect('/panel'); // redirect to site
            }
        }
        return $this->steam->redirect(); // redirect to Steam login page
    }

Now the problem arises when I try signing in with the remote project on my web server. By visiting mysite.com/login I get redirected to Steam as normal, but when I sign in, I just get redirected to the same Steam login page. I did some digging around, and it appears that requestIsValid() is returning false in SteamAuth.php every time. It looks like none of the GET parameters are being sent to the login page for some reason. I'm using the version that was just published a few days ago, v2.2.0

This problem only occurs on the remote project and not on my local project. I sign in on my local project by visiting localproject.app/login get redirected to Steam, login successfully, and get redirected to localproject.app/panel afterwards. The remote project loops the Steam login page over and over when attempting to sign in to Steam.

sanny-io commented 8 years ago

It's caused by a problem in the nginx configuration not taking args.

Go to your sites-enabled and open up your sites configuration. cd /etc/nginx/sites-enabled

Wherever you see try_files replace it with try_files $uri $uri/ /index.php$is_args$args;

Restart nginx. service nginx restart