Browse Source

finish updating to indieauth client

main
Aaron Parecki 4 years ago
parent
commit
f59b533461
2 changed files with 111 additions and 28 deletions
  1. +107
    -23
      composer.lock
  2. +4
    -5
      controllers/auth.php

+ 107
- 23
composer.lock View File

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "1d07c0c44cd10b3a4bc578895e82c03e",
"hash": "16c82a8bb785fbf1fccc57372f10c8f0",
"content-hash": "b0f983926c946d2fdc6ce5e2acd56076",
"packages": [
{
"name": "barnabywalters/mf-cleaner",
@ -44,7 +45,7 @@
}
],
"description": "Cleans up microformats2 array structures",
"time": "2014-10-06T23:11:15+00:00"
"time": "2014-10-06 23:11:15"
},
{
"name": "firebase/php-jwt",
@ -87,27 +88,27 @@
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"time": "2016-07-18T04:51:16+00:00"
"time": "2016-07-18 04:51:16"
},
{
"name": "indieauth/client",
"version": "0.2.4",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/indieweb/indieauth-client-php.git",
"reference": "2a7f8186085d06f0371a0199e103e10729782aea"
"reference": "02b6c7fc9bdfc51780df17a2ddc2349e79b8eaa3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/indieweb/indieauth-client-php/zipball/2a7f8186085d06f0371a0199e103e10729782aea",
"reference": "2a7f8186085d06f0371a0199e103e10729782aea",
"url": "https://api.github.com/repos/indieweb/indieauth-client-php/zipball/02b6c7fc9bdfc51780df17a2ddc2349e79b8eaa3",
"reference": "02b6c7fc9bdfc51780df17a2ddc2349e79b8eaa3",
"shasum": ""
},
"require": {
"barnabywalters/mf-cleaner": "0.*",
"indieweb/link-rel-parser": "0.1.*",
"mf2/mf2": "~0.3",
"php": ">5.3.0"
"indieweb/representative-h-card": "^0.1.2",
"mf2/mf2": ">=0.3.2",
"p3k/http": ">=0.1.6",
"php": ">5.6.0"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
@ -120,16 +121,16 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache 2.0"
"Apache-2.0"
],
"authors": [
{
"name": "Aaron Parecki",
"homepage": "http://aaronparecki.com"
"homepage": "https://aaronparecki.com"
}
],
"description": "IndieAuth Client Library",
"time": "2017-11-23T17:22:16+00:00"
"time": "2020-11-26 23:27:17"
},
{
"name": "indieweb/date-formatter",
@ -172,7 +173,7 @@
"microformats",
"microformats2"
],
"time": "2015-10-28T00:32:39+00:00"
"time": "2015-10-28 00:32:39"
},
{
"name": "indieweb/link-rel-parser",
@ -218,7 +219,52 @@
"indieweb",
"microformats2"
],
"time": "2013-12-23T00:14:58+00:00"
"time": "2013-12-23 00:14:58"
},
{
"name": "indieweb/representative-h-card",
"version": "0.1.2",
"source": {
"type": "git",
"url": "https://github.com/indieweb/representative-h-card-php.git",
"reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/indieweb/representative-h-card-php/zipball/b70b01bd0dd7f2a940602137335dbf46ab6e2e38",
"reference": "b70b01bd0dd7f2a940602137335dbf46ab6e2e38",
"shasum": ""
},
"require": {
"php": ">=5.4"
},
"require-dev": {
"mf2/mf2": "0.2.*",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"files": [
"src/mf2/representative-h-card.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Aaron Parecki",
"homepage": "http://aaronparecki.com"
}
],
"keywords": [
"h-card",
"indieweb",
"mf2",
"microformats"
],
"time": "2015-12-23 18:11:19"
},
{
"name": "j4mie/idiorm",
@ -276,7 +322,7 @@
"orm",
"query builder"
],
"time": "2013-12-12T10:25:27+00:00"
"time": "2013-12-12 10:25:27"
},
{
"name": "mf2/mf2",
@ -331,7 +377,7 @@
"parser",
"semantic"
],
"time": "2017-05-27T15:27:47+00:00"
"time": "2017-05-27 15:27:47"
},
{
"name": "minicodemonkey/amazon-alexa-php",
@ -370,7 +416,7 @@
}
],
"description": "Amazon Alexa interface for PHP",
"time": "2015-11-29T21:50:59+00:00"
"time": "2015-11-29 21:50:59"
},
{
"name": "mpratt/relativetime",
@ -418,7 +464,45 @@
"time",
"time-ago"
],
"time": "2015-12-24T12:43:04+00:00"
"time": "2015-12-24 12:43:04"
},
{
"name": "p3k/http",
"version": "0.1.11",
"source": {
"type": "git",
"url": "https://github.com/aaronpk/p3k-http.git",
"reference": "24d28287e0c5606aa45b23c6e3c17628d89468f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aaronpk/p3k-http/zipball/24d28287e0c5606aa45b23c6e3c17628d89468f7",
"reference": "24d28287e0c5606aa45b23c6e3c17628d89468f7",
"shasum": ""
},
"require": {
"indieweb/link-rel-parser": "0.1.*",
"mf2/mf2": ">=0.3.2"
},
"type": "library",
"autoload": {
"psr-4": {
"p3k\\": "src/p3k"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Parecki",
"homepage": "https://aaronparecki.com"
}
],
"description": "A simple wrapper API around the PHP curl functions",
"homepage": "https://github.com/aaronpk/p3k-http",
"time": "2020-02-19 03:00:09"
},
{
"name": "p3k/multipart",
@ -454,7 +538,7 @@
}
],
"description": "Multipart Encoding Library",
"time": "2015-07-16T19:28:02+00:00"
"time": "2015-07-16 19:28:02"
},
{
"name": "saltybeagle/savant3",
@ -489,7 +573,7 @@
}
],
"description": "Savant3 template engine",
"time": "2014-01-07T17:10:32+00:00"
"time": "2014-01-07 17:10:32"
},
{
"name": "slim/slim",
@ -532,7 +616,7 @@
"rest",
"router"
],
"time": "2012-12-13T02:15:50+00:00"
"time": "2012-12-13 02:15:50"
}
],
"packages-dev": [],

+ 4
- 5
controllers/auth.php View File

@ -218,7 +218,7 @@ $app->get('/auth/callback', function() use($app) {
// Verify the authorization endpoint matches
if($token['response']['me'] != $me) {
$newAuthorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($data['response']['me']);
$newAuthorizationEndpoint = IndieAuth\Client::discoverAuthorizationEndpoint($token['response']['me']);
if($newAuthorizationEndpoint != $authorizationEndpoint) {
render('auth_error', [
'title' => 'Error Signing In',
@ -265,7 +265,6 @@ $app->get('/auth/callback', function() use($app) {
return;
}
$user = ORM::for_table('users')->where('url', hostname($me))->find_one();
if($user) {
// Already logged in, update the last login date
@ -281,9 +280,9 @@ $app->get('/auth/callback', function() use($app) {
$user->last_login = date('Y-m-d H:i:s');
}
$user->micropub_endpoint = $micropubEndpoint;
$user->access_token = $token['auth']['access_token'];
$user->token_scope = $token['auth']['scope'];
$user->token_response = $token['response'];
$user->access_token = $token['response']['access_token'];
$user->token_scope = $token['response']['scope'];
$user->token_response = $token['raw_response'];
$user->save();
$_SESSION['user_id'] = $user->id();

Loading…
Cancel
Save