Add manual Micropub token generation for non-PKCE clients
iA Writer's IndieAuth client predates PKCE support in the spec, so it can't complete the normal authorization flow. Add an admin form to mint a token directly (reusing the existing TokenService), so it can be pasted into clients that support manual token setup instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017USyUg8PwuoDcHP8pv5xjy
This commit is contained in:
parent
9e9fbdc127
commit
568ae78864
12 changed files with 190 additions and 2 deletions
|
|
@ -6,7 +6,9 @@ namespace App\Http\Controllers\Admin;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\MicropubToken;
|
||||
use App\Services\TokenService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class TokensController extends Controller
|
||||
|
|
@ -21,6 +23,36 @@ class TokensController extends Controller
|
|||
return view('admin.tokens.index', compact('tokens'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to manually generate a new Micropub token.
|
||||
*
|
||||
* This is for clients (e.g. iA Writer) that don't support the IndieAuth
|
||||
* PKCE flow and instead expect to be given a token directly.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.tokens.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually generate a new Micropub token.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'client_id' => 'required|string',
|
||||
'scope' => 'required|array|min:1',
|
||||
]);
|
||||
|
||||
$token = resolve(TokenService::class)->getNewToken([
|
||||
'me' => config('app.url'),
|
||||
'client_id' => $validated['client_id'],
|
||||
'scope' => implode(' ', $validated['scope']),
|
||||
]);
|
||||
|
||||
return redirect('/admin/tokens')->with('new_token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke a Micropub token.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue