diff --git a/CHANGELOG.md b/CHANGELOG.md index 0501e18..96b4170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.3] 2024-06-15 +### Changed +- Added client metadata JSON endpoint and updated client_id in IndieAuth requests +- See https://github.com/indieweb/indieauth/issues/133 + ## [0.1.2] 2024-04-07 ### Added - Add `draft` scope and `post-status` support [#21](https://github.com/gRegorLove/indiebookclub/issues/21) diff --git a/app/Controller/AuthController.php b/app/Controller/AuthController.php index a90db8b..fbb05cd 100644 --- a/app/Controller/AuthController.php +++ b/app/Controller/AuthController.php @@ -26,11 +26,31 @@ class AuthController extends Controller { private function initClient(): void { - // The client ID should be the home page of your app. - Client::$clientID = sprintf('https://%s/', $_ENV['IBC_HOSTNAME']); + // The client ID is the URL that returns client information in JSON + // See https://github.com/indieweb/indieauth/issues/133 + Client::$clientID = $_ENV['IBC_BASE_URL'] . '/id'; // The redirect URL is where the user will be returned to after they approve the request. Client::$redirectURL = $_ENV['IBC_BASE_URL'] . $this->router->pathFor('auth_callback'); + + // Previously: The client ID should be the home page of your app. + // Client::$clientID = sprintf('https://%s/', $_ENV['IBC_HOSTNAME']); + } + + public function client_metadata( + ServerRequestInterface $request, + ResponseInterface $response, + array $args + ) { + return $response->withJson([ + 'client_id' => $_ENV['IBC_BASE_URL'] . '/id', + 'client_name' => 'indiebookclub', + 'client_uri' => $_ENV['IBC_BASE_URL'] . '/', + 'logo_uri' => $_ENV['IBC_BASE_URL'] . '/images/book.svg', + 'redirect_uris' => [ + $_ENV['IBC_BASE_URL'] . $this->router->pathFor('auth_callback'), + ], + ]); } /** diff --git a/app/routes.php b/app/routes.php index 8045630..e65cfb6 100644 --- a/app/routes.php +++ b/app/routes.php @@ -16,6 +16,8 @@ ->setName($prefix . '_re_authorize'); }); +$app->get('/id', 'AuthController:client_metadata') + ->setName('client_metadata'); $app->get('/', 'PageController:index') ->setName('index'); $app->get('/about', 'PageController:about') diff --git a/app/settings.php b/app/settings.php index 65ed1ff..0058392 100644 --- a/app/settings.php +++ b/app/settings.php @@ -4,7 +4,7 @@ return [ 'settings' => [ - 'version' => '0.1.1', + 'version' => '0.1.3', 'offline' => false, 'developer_ip' => '127.0.0.1', 'developer_domains' => [