-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uml 3122 one login api exception handling (#2436)
* UML-3122 add exception handling to one login api * add linting fixes to exception files
- Loading branch information
Showing
6 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
service-api/app/src/App/src/Exception/AuthorisationServiceException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Exception; | ||
|
||
use Exception; | ||
|
||
/** | ||
* Thrown when our OIDC Authorisation library encounters an error | ||
*/ | ||
class AuthorisationServiceException extends Exception | ||
{ | ||
} |
40 changes: 40 additions & 0 deletions
40
service-api/app/src/App/src/Service/Authentication/AuthorisationService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Service\Authentication; | ||
|
||
use App\Exception\AuthorisationServiceException; | ||
use Facile\OpenIDClient\Client\ClientInterface as OpenIDClient; | ||
use Facile\OpenIDClient\Service\AuthorizationService as FacileAuthorisationService; | ||
use JsonException; | ||
|
||
/** | ||
* Decorator class for Facile AuthorizationService | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
class AuthorisationService | ||
{ | ||
public function __construct(private FacileAuthorisationService $authorisationService) | ||
{ | ||
} | ||
|
||
/** | ||
* Decorates the return of FacileAuthorisationService::getAuthorisationUri() | ||
* | ||
* @throws AuthorisationServiceException | ||
*/ | ||
public function getAuthorisationUri(OpenIDClient $client, array $params = []): string | ||
{ | ||
try { | ||
return $this->authorisationService->getAuthorizationUri($client, $params); | ||
} catch (JsonException $e) { | ||
throw new AuthorisationServiceException( | ||
'JSON error encountered when fetching authorisation uri', | ||
500, | ||
$e | ||
); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
service-api/app/src/App/src/Service/Authentication/AuthorisationServiceBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Service\Authentication; | ||
|
||
use Facile\OpenIDClient\Service\Builder\AuthorizationServiceBuilder as FacileAuthorizationServiceBuilder; | ||
|
||
/** | ||
* Decorator class for Facile AuthorizationServiceBuilder | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
class AuthorisationServiceBuilder | ||
{ | ||
private FacileAuthorizationServiceBuilder $authorizationServiceBuilder; | ||
|
||
public function __construct() | ||
{ | ||
$this->authorizationServiceBuilder = new FacileAuthorizationServiceBuilder(); | ||
} | ||
|
||
/** | ||
* Decorates the return of FacileAuthorizationServiceBuilder::build() | ||
*/ | ||
public function build(): AuthorisationService | ||
{ | ||
return new AuthorisationService($this->authorizationServiceBuilder->build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters