Merge pull request #3 from gtoriadotnet/versioncompatibility-changes

Versioncompatibility for client/rcc
This commit is contained in:
Graphictoria 2022-04-03 15:11:44 -04:00 committed by GitHub
commit a7690eada2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 162 additions and 30 deletions

View File

@ -0,0 +1,21 @@
<?php
/*
Graphictoria 2022
Error helper
*/
namespace App\Helpers;
class ErrorHelper
{
/**
* Returns a JSON array with the error code and message.
*
* @return Response
*/
private static function error($data, $code = 400)
{
return response(['errors' => [$data]], 400);
}
}

View File

@ -2,31 +2,32 @@
/*
Graphictoria 2022
JSON Pretty Printer
Grid helper
*/
namespace App\Helpers;
use App\Helpers\COMHelper;
use Illuminate\Http\Request;
use App\Helpers\COMHelper;
use App\Models\WebsiteConfiguration;
class GridHelper
{
public static function isIpWhitelisted($request) {
public static function isIpWhitelisted(Request $request) {
$ip = $request->ip();
$whitelistedIps = explode(';', WebsiteConfiguration::where('name', 'WhitelistedIPs')->first()->value);
return in_array($ip, $whitelistedIps);
}
public static function isAccessKeyValid($request) {
public static function isAccessKeyValid(Request $request) {
$accessKey = WebsiteConfiguration::where('name', 'ComputeServiceAccessKey')->first()->value;
return ($request->header('AccessKey') == $accessKey);
}
public static function hasAllAccess($request) {
public static function hasAllAccess(Request $request) {
if(COMHelper::isCOM()) return true;
if(GridHelper::isIpWhitelisted($request) && GridHelper::isAccessKeyValid($request)) return true;

View File

@ -1,6 +1,6 @@
<?php
namespace App\Http\Controllers;
namespace App\Http\Controllers\Apis;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Cache;
use App\Helpers\JSON;
use App\Helpers\GridHelper;
use App\Helpers\ErrorHelper;
use App\Models\FFlag;
use App\Models\Fbucket;
@ -38,16 +39,6 @@ class AppSettings extends Controller
'Boolean' => 'Flag'
];
/**
* Returns a JSON array with the error code and message.
*
* @return Response
*/
private function error($data, $code = 400)
{
return response(['errors' => [$data]], 400);
}
/**
* Returns a JSON array of settings for the specified bucket.
*
@ -66,7 +57,7 @@ class AppSettings extends Controller
$bucketIds = array_merge($bucketIds, json_decode($primaryBucket->inheritedGroupIds));
if($primaryBucket->protected == 1 && !GridHelper::hasAllAccess($request)) {
return $this->error([
return ErrorHelper::error([
'code' => 2,
'message' => 'You do not have access to this bucket.'
], 401);
@ -98,7 +89,7 @@ class AppSettings extends Controller
return JSON::EncodeResponse($flags);
} else {
return $this->error([
return ErrorHelper::error([
'code' => 1,
'message' => 'The requested bucket does not exist.'
]);

View File

@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers\Apis;
use Illuminate\Http\Request;
use App\Models\WebsiteConfiguration;
use App\Helpers\GridHelper;
class VersionCompatibility extends Controller
{
function getVersions(Request $request)
{
if(!GridHelper::hasAllAccess($request)) {
return ErrorHelper::error([
'code' => 1,
'message' => 'You do not have access to this resource.'
], 401);
}
return Response()->json([
'data' => [
explode(';', WebsiteConfiguration::where('name', 'VersionCompatibilityVersions')->first()->value)
]
]);
}
function getMD5Hashes(Request $request)
{
if(!GridHelper::hasAllAccess($request)) {
return ErrorHelper::error([
'code' => 1,
'message' => 'You do not have access to this resource.'
], 401);
}
return Response()->json([
'data' => [
explode(';', WebsiteConfiguration::where('name', 'VersionCompatibilityHashes')->first()->value)
]
]);
}
}

View File

@ -25,4 +25,13 @@ class GamesController extends Controller
return response()->json(['available' => $status->operational])
->header('Content-Type', 'application/json');
}
public function validatePlaceJoin()
{
// todo: move to backend and make this actually return if the player is validated
// this is only here for testing
return response('true', null)
->header('Content-Type', 'text/plain');
}
}

View File

@ -17,11 +17,10 @@ class GridTest extends Controller
game:GetService("ContentProvider"):SetThreadPool(16)
game:GetService("Stats"):SetReportUrl("http://api.gtoria.net/teststat")
local p = game:GetService("Players"):CreateLocalPlayer(0)
p.CharacterAppearance = "http://api.gtoria.net/user/getCharacter.php?key=D869593BF742A42F79915993EF1DB&mode=ch&sid=1&uid=15"
p:LoadCharacter(false)
game:GetService("ContentProvider"):SetBaseUrl("http://www.roblox.com/")
game:LoadWorld(23173663)
return game:GetService("ThumbnailGenerator"):Click("PNG", 2048, 2048, true, false)
return game:GetService("ThumbnailGenerator"):Click("PNG", 1920, 1080, false, false)
TestScript;
$test = new SoapService('http://127.0.0.1:64989');

View File

@ -2,12 +2,12 @@
namespace App\Http\Controllers;
use App\Models\WebsiteConfiguration;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpFoundation\Cookie;
use App\Models\WebsiteConfiguration;
class MaintenanceController extends Controller
{
/**

View File

@ -50,6 +50,11 @@ class RouteServiceProvider extends ServiceProvider
->namespace($this->namespace)
->group(base_path('routes/appsettings.php'));
Route::domain('versioncompatibility.api.' . env('APP_URL'))
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/versioncompatibility.php'));
Route::domain('impulse.' . env('APP_URL'))
->middleware('admin')
->namespace($this->namespace)

View File

@ -23,7 +23,7 @@ class CreateFflagsTable extends Migration
Schema::create('fflags', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('value');
$table->longText('value');
$table->enum('dataType', ['Log', 'Int', 'String', 'Boolean']);
$table->enum('type', ['Unscoped', 'Fast', 'Dynamic', 'Synchronised']);
$table->bigInteger('bucketId');

View File

@ -33,5 +33,15 @@ class WebConfigurationSeeder extends Seeder
'name' => 'WhitelistedIPs',
'value' => '127.0.0.1'
]);
WebsiteConfiguration::create([
'name' => 'VersionCompatibilityVersions',
'value' => '0.1.0pcplayer' // version1;version2;version3
]);
WebsiteConfiguration::create([
'name' => 'VersionCompatibilityHashes',
'value' => 'debughash' // hash1;hash2;hash3
]);
}
}

View File

@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="102.4" height="102.4" viewBox="0 0 1024 1024">
<defs>
<style>
.cls-1 {
fill: currentcolor;
fill-rule: evenodd;
}
</style>
</defs>
<path id="Polygon_1" data-name="Polygon 1" class="cls-1" d="M718.719-.012L1020.99,562.653,579.262,1024,3.994,746.459,90.183,113.587ZM637.405,554.647c-1.474-51.324-42.032-83.369-102.451-104.469-41.717-14.529-68.9-18.909-69.359-34.867-0.341-11.861,14.321-22,35.191-22.618,18.26-.537,47.9,6.576,59.806,24.572l57.1-53.048c-12.388-26.4-43.108-46.43-83.659-53.439l-1.35-47.011-79.209,2.33,1.393,48.521c-52.507,14.71-91.52,52.981-90.146,100.855,1.5,52.4,43.837,80.079,92.761,97.632,37.9,13.993,77.486,28.584,78,46.483,0.409,14.233-20.493,21.97-42.074,22.605-32.016.942-62.031-11.125-78.534-32.006l-59.849,56.582c16.806,31.448,59.675,53.065,109.907,58.278l1.319,45.933,79.209-2.33-1.419-49.384C598.437,644.069,638.892,606.4,637.405,554.647ZM559.964,929.165L83.555,696.984,157.472,172.64,679.564,80.758,928.319,548.316Zm-10.7-92.114L167.181,650.975,226.463,230.75l418.723-73.637,199.5,374.714Z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -51,8 +51,11 @@ const Navbar = (props) => {
<>
<SearchBar />
{props.user?
<div className={`flex row`}>
<div className={`flex row col flex alc`}>Bank: ${props.user.bank}</div>
<div className='flex'>
<p className='my-auto me-3 text-muted'>
<img src='/images/symbols/token.svg' height='20' width='20' className='img-fluid me-1' />
${props.user.bank}
</p>
<li className="nav-item dropdown col flex alc">
<button className="btn btn-secondary nav-link dropdown-toggle" href="#" id="graphictoria-nav-dropdown" role="button" data-bs-toggle="dropdown" area-expanded="false">{props.user.username}</button>
<ul className="dropdown-menu graphictoria-nav-dropdown" area-labelledby="graphictoria-nav-dropdown">

View File

@ -104,7 +104,6 @@ const App = () => {
}
const authMiddleware = (to, from, next) => {
console.log(user);
if (to.meta.auth) {
if (user)
next();

View File

@ -43,7 +43,7 @@ const LoginForm = (props) => {
<form onSubmit={(e)=>{
e.preventDefault();
SubmitLogin(new FormData(e.target));
}} class="fs">
}} className="fs">
<input type="username" className={`form-control mb-4 ${(validity.inputs.find(input=>input == `username`)? `is-invalid` : ``)}`} placeholder="Username" name="username"/>
<input type="password" className={`form-control mb-4 ${(validity.inputs.find(input=>input == `password`)? `is-invalid` : ``)}`} placeholder="Password" name="password"/>
<div className="d-flex mb-3">

View File

@ -2,7 +2,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AppSettings;
use App\Http\Controllers\Apis\AppSettings;
/*
|--------------------------------------------------------------------------

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Apis\VersionCompatibility;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::get('/', function(){
return 'API OK';
});
// RCC Security Backbone
Route::get('/GetAllowedSecurityVersions', 'VersionCompatibility@getVersions');
Route::get('/GetAllowedSecurityKeys', 'VersionCompatibility@getVersions');
Route::get('/GetAllowedMD5Hashes', 'VersionCompatibility@getMD5Hashes');
Route::get('/GetAllowedMemHashes', 'VersionCompatibility@getMemHashes');
// Client/Launcher apis
Route::get('/GetCurrentClientVersionUpload', 'VersionCompatibility@getClientVersion');
Route::fallback(function(){
return response('{"errors":[{"code":404,"message":"NotFound"}]}', 404)
->header('Cache-Control', 'private')
->header('Content-Type', 'application/json; charset=utf-8');
});

View File

@ -1,6 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\GamesController;
use App\Http\Controllers\GridTest;
/*
@ -14,6 +15,10 @@ use App\Http\Controllers\GridTest;
|
*/
// client apis
Route::get('/universes/validate-place-join', 'GamesController@validatePlaceJoin');
// other
Route::get('/javascript', function(){
return view('javascript');
})->middleware('auth');