Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ Sources: [API routes](routes/api.php), [API controllers](app/Http/Controllers/Ap

### Signed API and devices

An app can use the same `/api/v1` for you with signed requests. It keeps an SSH key on the device and signs every request with it; there are no passwords or API tokens. To sign in, the app opens `/mobile/authorize` on the web: sign in with GitHub if needed, check the key's fingerprint, and approve it. The key then becomes one of your devices, and it does not need to be on your GitHub account. A key that is only on GitHub, such as a GitHub Actions key, cannot use the signed API.
An app can use the same `/api/v1` for you with signed requests. It keeps an SSH key on the device and signs every request with it; there are no passwords or API tokens. To sign in, the app opens `/mobile/authorize` on the web. A guest goes straight to GitHub and returns to that page; someone already signed in checks the key's fingerprint and approves it. The key then becomes one of your devices, and it does not need to be on your GitHub account. A key that is only on GitHub, such as a GitHub Actions key, cannot use the signed API.

A signed request sees what the web shows you, such as your own pending commits. It can also, with the web's validation, moderation, and rate limits:

Expand Down
6 changes: 5 additions & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@

$middleware->encryptCookies(except: ['appearance', 'sidebar_state', 'who_to_follow', 'who_to_follow_round', 'lane_dimming', 'replies_per_page']);

$middleware->redirectGuestsTo(fn (): string => route('home'));
// Approving the app is the one page a guest should leave for GitHub, then return to. Every other page
// they open while signed out stays the log. Locally, sign-in is the modal on that log.
$middleware->redirectGuestsTo(fn (Request $request): string => $request->routeIs('mobile-authorization.show') && ! app()->isLocal()
? route('login')
: route('home'));
$middleware->redirectUsersTo(fn (Request $request): string => route('log.show', $request->user()->log ?? Log::Following));

// Rate limits apply to the user authenticated by their SSH signature...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Queue::fake();
fakeGitHubSponsorsListing();

$this->get(route('mobile-authorization.show', $this->parameters))->assertRedirectToRoute('home');
$this->get(route('mobile-authorization.show', $this->parameters))->assertRedirectToRoute('login');

$user = User::factory()->create(['github_id' => '583231']);

Expand Down