-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from classid/feature/authenticate-service
authenticate service for login
- Loading branch information
Showing
4 changed files
with
52 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Classid\SsoDriver; | ||
|
||
use Classid\SsoDriver\Exceptions\InvalidClientCredentials; | ||
use Classid\SsoDriver\Exceptions\InvalidRetryGenerateException; | ||
use Classid\SsoDriver\Exceptions\SSODriverException; | ||
use Classid\SsoDriver\Exceptions\UnknownErrorHandlerException; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class AuthService | ||
{ | ||
public MumtazSSOService $mumtazSSOService; | ||
public function __construct() | ||
{ | ||
$this->mumtazSSOService = new MumtazSSOService(); | ||
} | ||
|
||
/** | ||
* @param array $credentials | ||
* @return mixed | ||
* @throws InvalidClientCredentials | ||
* @throws InvalidRetryGenerateException | ||
* @throws SSODriverException | ||
* @throws UnknownErrorHandlerException | ||
*/ | ||
public function authenticate(array $credentials): mixed | ||
{ | ||
return $this->mumtazSSOService->setAuthorizationToken() | ||
->getResponse(function (MumtazSSOService $service) use ($credentials) { | ||
return Http::withHeaders($service->getHeaders())->post($service->getBaseUrl() . "/api/v1/auth", [ | ||
"username" => $credentials["username"], | ||
"password" => $credentials["password"], | ||
"institution_id" => $credentials["institution_id"], //todo : hardcode for integration testing | ||
]); | ||
}); | ||
} | ||
} |
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
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