friendship ended with social-app. php is my new best friend

check for username

Changed files
+43 -41
+43 -41
index.php
··· 182 182 }); 183 183 184 184 Flight::route('/login', function(): void { 185 + if (isset($_GET['username'])) { 185 186 $username = $_GET['username']; 186 - $bskyToucher = new BskyToucher(); 187 - $userInfo = $bskyToucher->getUserInfo($username); 188 - if (!$userInfo) die(1); 189 - $pds = $userInfo->pds; 190 - $options = new OAuthOptions([ 191 - 'key' => 'https://'.SITE_DOMAIN.CLIENT_ID, 192 - 'secret' => CLIENT_SECRET, 193 - 'callbackURL' => 'https://'.SITE_DOMAIN.'/login', 194 - 'sessionStart' => true, 195 - 'sessionStorageVar' => 'sbs_'.SITE_DOMAIN 196 - ]); 197 - $storage = new SessionStorage($options); 198 - $connector = new React\Socket\Connector([ 199 - 'dns' => '1.1.1.1' 200 - ]); 201 - $http = new React\Http\Browser($connector); 202 - $httpFactory = new HttpFactory(); 203 - $token_builder = Builder::new(new JoseEncoder(), ChainedFormatter::default()); 204 - $algorithm = new Sha256(); 205 - $signing_key = InMemory::file(CERT_PATH); 206 - $now = new DateTimeImmutable(); 207 - $token = $token_builder 208 - ->withHeader('alg', 'ES256') 209 - ->withHeader('typ', 'JWT') 210 - ->withHeader('kid', 'ocwgKj_O7H9at1sL6yWf9ZZ82NOM7D0xlN8HGIyWH6M') 211 - ->issuedBy('https://'.SITE_DOMAIN.CLIENT_ID) 212 - ->identifiedBy(uniqid()) 213 - ->relatedTo('https://'.SITE_DOMAIN.CLIENT_ID) 214 - ->permittedFor($pds) 215 - ->issuedAt($now->modify('-5 seconds')) 216 - ->getToken($algorithm, $signing_key); 217 - $client = new GuzzleHttp\Client([ 218 - 'verify' => true, 219 - 'headers' => [ 220 - 'User-Agent' => USER_AGENT_STR, 221 - 'Authorization' => 'Bearer: '.$token->toString() 222 - ] 223 - ]); 224 - $provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory); 225 - $provider->setPds($pds); 226 - $name = $provider->getName(); 187 + $bskyToucher = new BskyToucher(); 188 + $userInfo = $bskyToucher->getUserInfo($username); 189 + if (!$userInfo) die(1); 190 + $pds = $userInfo->pds; 191 + $options = new OAuthOptions([ 192 + 'key' => 'https://'.SITE_DOMAIN.CLIENT_ID, 193 + 'secret' => CLIENT_SECRET, 194 + 'callbackURL' => 'https://'.SITE_DOMAIN.'/login', 195 + 'sessionStart' => true, 196 + 'sessionStorageVar' => 'sbs_'.SITE_DOMAIN 197 + ]); 198 + $storage = new SessionStorage($options); 199 + $connector = new React\Socket\Connector([ 200 + 'dns' => '1.1.1.1' 201 + ]); 202 + $http = new React\Http\Browser($connector); 203 + $httpFactory = new HttpFactory(); 204 + $token_builder = Builder::new(new JoseEncoder(), ChainedFormatter::default()); 205 + $algorithm = new Sha256(); 206 + $signing_key = InMemory::file(CERT_PATH); 207 + $now = new DateTimeImmutable(); 208 + $token = $token_builder 209 + ->withHeader('alg', 'ES256') 210 + ->withHeader('typ', 'JWT') 211 + ->withHeader('kid', 'ocwgKj_O7H9at1sL6yWf9ZZ82NOM7D0xlN8HGIyWH6M') 212 + ->issuedBy('https://'.SITE_DOMAIN.CLIENT_ID) 213 + ->identifiedBy(uniqid()) 214 + ->relatedTo('https://'.SITE_DOMAIN.CLIENT_ID) 215 + ->permittedFor($pds) 216 + ->issuedAt($now->modify('-5 seconds')) 217 + ->getToken($algorithm, $signing_key); 218 + $client = new GuzzleHttp\Client([ 219 + 'verify' => true, 220 + 'headers' => [ 221 + 'User-Agent' => USER_AGENT_STR, 222 + 'Authorization' => 'Bearer: '.$token->toString() 223 + ] 224 + ]); 225 + $provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory); 226 + $provider->setPds($pds); 227 + $name = $provider->getName(); 228 + } 227 229 if (isset($_GET['login']) && $_GET['login'] === $name) { 228 230 $auth_url = $provider->getAuthorizationUrl([ 229 231 'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',