Several times I have been asked if there is a token endpoint available to be used together with Selfauth. A minimal solution that would just work for issuing access tokens that is self-hostable on a server with PHP.
I do not have a need for a token endpoint like this myself, thus developing one would go against my selfdogfooding principles. But because I have a general interest in the IndieAuth specification, here is an implementation anyway!
Download the latest release from GitHub and extract the files.
Create an SQLite database; these instructions assume the database is called
You can do this from the command line:
bash sqlite3 tokens.db < schema.sql
If you prefer, create the SQLite database by your favourite means and use
schema.sqlto create the expected tables.
Define trusted authorization endpoints in the
settingstable of the SQLite database. Mintoken will only check codes with these endpoints, and takes the
mevalue they return as trusted without further verification.
E.g. if we take the example setup for Selfauth, the endpoint
https://example.com/auth/should be whitelisted.
From the command line:
bash sqlite3 tokens.db 'INSERT INTO settings VALUES ("endpoint", "https://example.com/auth/");'
Upload the SQLite database to a secure directory on your server. Make sure it is not publicly available to the web! This is very important for security reasons.
endpoint.phpso line 5 defines the correct path to the SQLite database as the value for
You should use the full path to
tokens.db. For example,
endpoint.phpanywhere on your server where it is available to the web. (This can be in the same folder as Selfauth, for simplicity.)
Make the token endpoint discoverable. Either by defining a
LinkHTTP header, or adding the following to the
<head>of the pages where you also link to your
html <link rel="token_endpoint" href="https://example.com/auth/endpoint.php">
hrefmust point at your
The BSD Zero Clause License (0BSD). Please see the LICENSE file for more information.