Adds sha256 to etsy pkce based auth

Updates requests to use hash instead of plain text
This commit is contained in:
wess
2023-03-21 14:19:34 -04:00
parent 5f1fb5a5ef
commit db22310359
3 changed files with 46 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
default: build
prune:
@docker volume prune
down:
@docker compose down -v
up:
@docker compose up --build -d
build: down up
logs:
@docker compose logs appwrite
dblogs:
@docker compose logs appwrite-worker-databases
test:
@docker compose exec appwrite test
dbtest:
@docker compose exec appwrite test /usr/src/code/tests/e2e/Services/Databases/DatabasesCustomClientTest.php
testall:
@docker compose exec appwrite test
+19 -2
View File
@@ -39,6 +39,11 @@ class Etsy extends OAuth2
*/
private string $pkce = '';
/**
* @var string
*/
private string $pkceHash = '';
/**
* @return string
*/
@@ -51,6 +56,18 @@ class Etsy extends OAuth2
return $this->pkce;
}
/**
* @return string
*/
private function getPKCEHash(): string
{
if (empty($this->pkceHash)) {
$this->pkceHash = hash('sha256', $this->getPKCE());
}
return $this->pkceHash;
}
/**
* @return string
*/
@@ -70,7 +87,7 @@ class Etsy extends OAuth2
'response_type' => 'code',
'state' => \json_encode($this->state),
'scope' => $this->scopes,
'code_challenge' => $this->getPKCE(),
'code_challenge' => $this->getPKCEHash(),
'code_challenge_method' => 'S256',
]);
}
@@ -94,7 +111,7 @@ class Etsy extends OAuth2
'client_id' => $this->appID,
'redirect_uri' => $this->callback,
'code' => $code,
'code_verifier' => $this->getPKCE(),
'code_verifier' => $this->getPKCEHash(),
])
), true);
}