Skip to content

Commit

Permalink
fix: method signatures after 1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Sep 5, 2024
1 parent 1a468a4 commit 2c8b742
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
34 changes: 22 additions & 12 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright MITRE 2020
*
* OpenIDConnectClient for PHP5
* OpenIDConnectClient for PHP7+
* Author: Michael Jett <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand All @@ -25,7 +25,6 @@

use Error;
use Exception;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA;
use phpseclib3\Math\BigInteger;
use stdClass;
Expand Down Expand Up @@ -380,7 +379,7 @@ public function authenticate(): bool
$accessToken = $_REQUEST['access_token'] ?? null;

// Do an OpenID Connect session check
if (!isset($_REQUEST['state']) || ($_REQUEST['state'] !== $this->getState())) {
if (!isset($_REQUEST['state']) || ($_REQUEST['state'] !== $this->getState())) {
throw new OpenIDConnectClientException('Unable to determine state');
}

Expand Down Expand Up @@ -1221,10 +1220,9 @@ protected function urlEncode(string $str): string
/**
* @param string $jwt encoded JWT
* @param int $section the section we would like to decode
* @return object
* @return object|null
*/
protected function decodeJWT(string $jwt, int $section = 0): stdClass {

protected function decodeJWT(string $jwt, int $section = 0) {
$parts = explode('.', $jwt);
return json_decode(base64url_decode($parts[$section]), false);
}
Expand Down Expand Up @@ -1688,7 +1686,10 @@ public function revokeToken(string $token, string $token_type_hint = '', string
return json_decode($this->fetchURL($revocation_endpoint, $post_params, $headers), false);
}

public function getClientName(): string
/**
* @return string|null
*/
public function getClientName()
{
return $this->clientName;
}
Expand All @@ -1698,14 +1699,14 @@ public function setClientName(string $clientName) {
}

/**
* @return string
* @return string|null
*/
public function getClientID() {
return $this->clientID;
}

/**
* @return string
* @return string|null
*/
public function getClientSecret() {
return $this->clientSecret;
Expand All @@ -1720,17 +1721,26 @@ public function setAccessToken(string $accessToken) {
$this->accessToken = $accessToken;
}

public function getAccessToken(): string
/**
* @return string|null
*/
public function getAccessToken()
{
return $this->accessToken;
}

public function getRefreshToken(): string
/**
* @return string|null
*/
public function getRefreshToken()
{
return $this->refreshToken;
}

public function getIdToken(): string
/**
* @return string|null
*/
public function getIdToken()
{
return $this->idToken;
}
Expand Down
23 changes: 20 additions & 3 deletions tests/OpenIDConnectClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@

class OpenIDConnectClientTest extends TestCase
{
/**
* @return void
*/
public function testJWTDecode()
{
$client = new OpenIDConnectClient();
$client->setAccessToken('');
$header = $client->getAccessTokenHeader();
self::assertEquals('', $header);
}

public function testGetNull()
{
$client = new OpenIDConnectClient();
self::assertNull($client->getAccessToken());
self::assertNull($client->getRefreshToken());
self::assertNull($client->getIdToken());
self::assertNull($client->getClientName());
self::assertNull($client->getClientID());
self::assertNull($client->getClientSecret());
self::assertNull($client->getCertPath());
}

public function testGetRedirectURL()
{
$client = new OpenIDConnectClient();
Expand Down

0 comments on commit 2c8b742

Please sign in to comment.