codigo actual del servidor, con avances de joan

This commit is contained in:
Jose Sanchez
2023-08-07 15:52:04 -04:00
commit 3cd9b8bbe8
3070 changed files with 532255 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Services\Revoke;
use Illuminate\Support\Facades\Http;
class AppleRevoke implements ProviderRevoke
{
public function apply()
{
$grant_type = "refresh_token";
$refresh_token = auth()->user()->refresh_token;
$client_id = env('SIGN_IN_WITH_APPLE_CLIENT_ID');
$client_secret = env('SIGN_IN_WITH_APPLE_CLIENT_SECRET');
$redirect_uri = env('SIGN_IN_WITH_APPLE_REDIRECT');
$server_output = Http::asForm()->post('https://appleid.apple.com/auth/token', [
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => $grant_type,
'refresh_token' => $refresh_token,
'redirect_uri' => $redirect_uri,
]);
$access_token = $server_output->object()->access_token;
$revoke_output = Http::asForm()->post('https://appleid.apple.com/auth/revoke', [
'client_id' => $client_id,
'client_secret' => $client_secret,
'token_type_hint' => $grant_type,
'token' => $access_token,
]);
return $revoke_output->ok();
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Services\Revoke;
use GuzzleHttp\Client;
class FacebookRevoke implements ProviderRevoke
{
public function apply()
{
$token = auth()->user()->access_token;
$http = new Client();
$response = $http->delete("https://graph.facebook.com/v3.0/".auth()->user()->provider_id."/permissions?access_token={$token}");
return $response->getStatusCode();
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Services\Revoke;
class GoogleRevoke implements ProviderRevoke
{
public function apply()
{
$token = auth()->user()->access_token;
$ch = curl_init("https://oauth2.googleapis.com/revoke?token={$token}");
$header = array(
'Content-Type:application/x-www-form-urlencoded'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
$resultdata = curl_exec($ch);
$response = curl_getinfo($ch);
curl_close($ch);
return $response['http_code'];
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Services\Revoke;
interface ProviderRevoke
{
/**
* Apply a given search value to the builder instance.
*
* @param Builder $builder
* @param mixed $value
* @return Builder $builder
*/
public function apply();
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Services\Revoke;
class TwitterRevoke implements ProviderRevoke
{
public function apply()
{
$token = auth()->user()->access_token;
$client_id = env('TWITTER_CLIENT_ID');
$request_data = array('client_id' => $client_id, 'token' => $token);
$request_data_json = json_encode($request_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.twitter.com/2/oauth2/revoke?client_id=' . $client_id . '&token=' . $token . '&token_type_hint=access_token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_data_json);
$header = array(
'Content-Type:application/x-www-form-urlencoded'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_exec($ch);
$response = curl_getinfo($ch);
curl_close($ch);
return $response['http_code'];
}
}