Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zegnat/php-mintoken
A minimal IndieAuth compatible Token Endpoint.
https://github.com/zegnat/php-mintoken
indieauth indieweb oauth2 token-endpoint
Last synced: 4 months ago
JSON representation
A minimal IndieAuth compatible Token Endpoint.
- Host: GitHub
- URL: https://github.com/zegnat/php-mintoken
- Owner: Zegnat
- License: 0bsd
- Created: 2018-05-06T12:10:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-29T14:49:58.000Z (about 4 years ago)
- Last Synced: 2024-04-06T05:03:09.844Z (10 months ago)
- Topics: indieauth, indieweb, oauth2, token-endpoint
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 14
- Watchers: 8
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mintoken
A minimal [IndieAuth][] compatible [Token Endpoint][].
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!
[IndieAuth]: https://indieauth.net/
[Token Endpoint]: https://indieauth.spec.indieweb.org/#token-endpoint
[Selfauth]: https://github.com/Inklings-io/selfauth
[selfdogfooding]: https://indieweb.org/selfdogfood## Setup
1. Download [the latest release](https://github.com/Zegnat/php-mintoken/releases/latest) from GitHub and extract the files.
2. Create an SQLite database; these instructions assume the database is called `tokens.db`.
**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.sql` to create the expected tables.
3. Define trusted authorization endpoints in the `settings` table of the SQLite database. Mintoken will only check codes with these endpoints, and takes the `me` value they return as trusted without further verification.
E.g. if we take [the example setup for Selfauth](https://github.com/Inklings-io/selfauth#setup), 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/");'
```
4. 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.
5. Edit `endpoint.php` so line 5 defines the correct path to the SQLite database as the value for `MINTOKEN_SQLITE_PATH`.
You should use the full path to `tokens.db`. For example, `define('MINTOKEN_SQLITE_PATH', '../../tokens.db');`
6. Put `endpoint.php` anywhere on your server where it is available to the web. (This can be in the same folder as Selfauth, for simplicity.)
7. Make the token endpoint discoverable. Either by defining a `Link` HTTP header, or adding the following to the `` of the pages where you also link to your `authorization_endpoint`:
```html
```
(The `href` must point at your `endpoint.php` file.)## License
The BSD Zero Clause License (0BSD). Please see the LICENSE file for
more information.