Skip to content

Instantly share code, notes, and snippets.

@barnabywalters
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barnabywalters/70d290c3e738c713fa55 to your computer and use it in GitHub Desktop.
Save barnabywalters/70d290c3e738c713fa55 to your computer and use it in GitHub Desktop.
indieauth client/server setup code
<?php
// Create a micropub client app — allows users to log in and authorize this app to make requests on their behalf to,
// e.g. a micropub endpoint, authenticates requests based on remember-me cookie.
// $dataToCookie and $dataFromCookie map between the array of information about the current user and the string value
// stored in the remember-me cookie
//
// Adds routes:
// /login
// /authorize
// /logout
//
// Adds ->before() handler which attaches data about the current user, which scopes they’ve granted this app (if any)
// their URL, access token and micropub endpoint to $request.
$app->mount('/', Authentication\client($app, $dataToCookie, $dataFromCookie));
// Create a micropub server app + token provider — creates token-providing and authorizing endpoints, allows users to
// authorize other apps to make requests to this one on their behalf, authenticates requests based on access tokens.
// $dataToToken and $dataFromToken map the access token granted to+used by apps and a user+client id+granted scopes
//
// Adds routes:
// /token
//
// Adds ->before() handler which attaches data about the current user, which app they’re using, what scopes they’re
// granted on this server to $request.
$app->mount('/', Authentication\server($app, $dataToToken, $dataFromToken));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment