惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 聂微东
MyScale Blog
MyScale Blog
H
Help Net Security
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏

Feed of "schmarty/gem-diamond"

issue when using indieauth[dot]com? gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond proxy for profile images gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond gem-diamond
gem-diamond
schmarty · 2025-02-02 · via Feed of "schmarty/gem-diamond"

共有 2 个文件被更改,包括 93 次插入25 次删除

@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
namespace App\IndieAuth;
use IndieAuth\Client as IndieAuthClient;
class Client extends IndieAuthClient {
/**
* Start the authorization process. Discovers the user's auth
* endpoints (or falls back to indielogin.com).
* Reverses IndieAuth\Client behavior where `$authorizationEndpoint` arg
* takes precedence over user's configured auth endpoint. In this case, it's
* the fallback.
* I'm sure this reversal won't cause any future confusion or issues. 🙃
*/
public static function begin($url, $scope=false, $fallbackAuthorizationEndpoint=false) {
if(!isset(self::$clientID) || !isset(self::$redirectURL)) {
return self::_errorResponse(
'not_configured',
'Before you can begin, you need to configure the clientID and redirectURL of the IndieAuth client'
);
}
$errorCode = false;
$url = self::normalizeMeURL($url);
$_SESSION['indieauth_entered_url'] = $url;
if(!$url) {
return self::_errorResponse('invalid_url', 'The URL provided was invalid');
}
$metadataEndpoint = self::discoverMetadataEndpoint($url);
if ($metadataEndpoint) {
$response = self::discoverIssuer($metadataEndpoint);
if ($response instanceof ErrorResponse) {
return $response->getArray();
}
$_SESSION['indieauth_issuer'] = $response;
}
$authorizationEndpoint = static::discoverAuthorizationEndpoint($url);
if((!$authorizationEndpoint) && (!$fallbackAuthorizationEndpoint)) {
// didn't find an auth endpoint and no fallback passed in. we're stuck.
return self::_errorResponse('missing_authorization_endpoint', 'Could not find your authorization endpoint');
}
$authorizationEndpoint = $fallbackAuthorizationEndpoint;
$scopes = self::parseNonProfileScopes($scope);
if(count($scopes)) {
$tokenEndpoint = static::discoverTokenEndpoint($url);
if(!$tokenEndpoint) {
return self::_errorResponse(
'missing_token_endpoint',
'Could not find your token endpoint. The token endpoint is required when requesting non-profile scopes'
);
}
}
$state = self::generateStateParameter();
$codeVerifier = self::generatePKCECodeVerifier();
$_SESSION['indieauth_state'] = $state;
$_SESSION['indieauth_code_verifier'] = $codeVerifier;
$_SESSION['indieauth_authorization_endpoint'] = $authorizationEndpoint;
if(isset($tokenEndpoint)) {
$_SESSION['indieauth_token_endpoint'] = $tokenEndpoint;
}
$authorizationURL = self::buildAuthorizationURL($authorizationEndpoint, [
'me' => $url,
'redirect_uri' => self::$redirectURL,
'client_id' => self::$clientID,
'state' => $state,
'code_verifier' => $codeVerifier,
'scope' => $scope,
]);
return [$authorizationURL, false];
}
}
@ -5,6 +5,8 @@ namespace App;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use App\IndieAuth;
class IndieAuthController extends \Schmarty\Micropubkit\IndieAuthController {
/**
@ -20,34 +22,12 @@ class IndieAuthController extends \Schmarty\Micropubkit\IndieAuthController {
return $this->error_redirect('missing_url', 'Website URL is required');
}
$url = \IndieAuth\Client::normalizeMeURL($params['me']);
$url = $params['me'];
list($authorizationURL, $error) = \IndieAuth\Client::begin($url, $this->scopes);
list($authorizationURL, $error) = IndieAuth\Client::begin($url, $this->scopes, 'https://indielogin.com/auth');
if($error) {
// use indielogin instead
// NOTE: this duplicates a _bunch_ of \IndieAuth\Client::begin. Smells like
// a refactor maybe?
$state = \IndieAuth\Client::generateStateParameter();
$codeVerifier = \IndieAuth\Client::generatePKCECodeVerifier();
// set up session info so \IndieAuth\Client can find it later
$_SESSION['indieauth_entered_url'] = $url;
$_SESSION['indieauth_state'] = $state;
$_SESSION['indieauth_code_verifier'] = $codeVerifier;
$_SESSION['indieauth_authorization_endpoint'] = 'https://indielogin.com/auth';
$authorizationURL = \IndieAuth\Client::buildAuthorizationURL(
"https://indielogin.com/auth",
[
'me' => $url,
'redirect_uri' => \IndieAuth\Client::$redirectURL,
'client_id' => \IndieAuth\Client::$clientID,
'code_verifier' => $codeVerifier,
'state' => $state,
]
);
return $this->error_redirect($error['error'], $error['error_description']);
}
return $this->response->withHeader('Location', $authorizationURL)->withStatus(302);