+15
-19
index.php
+15
-19
index.php
···
176
176
});
177
177
178
178
Flight::route('/login', function(): void {
179
+
$username = $_GET['username'];
180
+
$bskyToucher = new BskyToucher();
181
+
$userInfo = $bskyToucher->getUserInfo($username);
182
+
if (!$userInfo) die(1);
183
+
$pds = $userInfo->pds;
179
184
$options = new OAuthOptions([
180
185
'key' => 'https://'.SITE_DOMAIN.CLIENT_ID,
181
186
'secret' => CLIENT_SECRET,
···
187
192
]);
188
193
$http = new React\Http\Browser($connector);
189
194
$httpFactory = new HttpFactory();
190
-
$client = new GuzzleHttp\Client([
191
-
'verify' => true,
192
-
'headers' => [
193
-
'User-Agent' => USER_AGENT_STR
194
-
]
195
-
]);
196
-
$provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory);
197
-
$name = $provider->getName();
198
-
$username = $_GET['username'];
199
-
$bskyToucher = new BskyToucher();
200
-
$userInfo = $bskyToucher->getUserInfo($username);
201
-
if (!$userInfo) die(1);
202
-
$pds = $userInfo->pds;
203
-
$provider->setPds($pds);
204
195
$token_builder = Builder::new(new JoseEncoder(), ChainedFormatter::default());
205
196
$algorithm = new Sha256();
206
197
$signing_key = InMemory::file(CERT_PATH);
···
213
204
->permittedFor('did:web:'.str_replace("/", "", str_replace("https://", "", $pds)))
214
205
->issuedAt($now)
215
206
->getToken($algorithm, $signing_key);
216
-
print_r($token->toString());
217
-
218
-
$client->setDefaultOption('headers', [
219
-
'User-Agent' => USER_AGENT_STR,
220
-
'Authorization' => 'Bearer: '.$token->toString()
207
+
$client = new GuzzleHttp\Client([
208
+
'verify' => true,
209
+
'headers' => [
210
+
'User-Agent' => USER_AGENT_STR,
211
+
'Authorization' => 'Bearer: '.$token->toString()
212
+
]
221
213
]);
214
+
$provider = new BskyProvider($options, $client, $httpFactory, $httpFactory, $httpFactory);
215
+
$provider->setPds($pds);
216
+
$name = $provider->getName();
217
+
222
218
if (isset($_GET['login']) && $_GET['login'] === $name) {
223
219
$auth_url = $provider->getAuthorizationUrl();
224
220
header('Location: '.$auth_url);