Skip to content

Commit 7f933d8

Browse files
authored
Added public method to get the authorization URL
Since frameworks handles redirects with responses it should be better to have a method to get the authorization URL without redirect
1 parent e28ab77 commit 7f933d8

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/OpenIDConnectClient.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,13 @@ protected function generateRandString() {
662662
};
663663
}
664664

665-
/**
666-
* Start Here
667-
* @return void
668-
* @throws OpenIDConnectClientException
669-
*/
670-
private function requestAuthorization() {
671-
672-
$auth_endpoint = $this->getProviderConfigValue('authorization_endpoint');
665+
/**
666+
* Get the authorization URL
667+
*
668+
* @return string
669+
*/
670+
public function getAuthorizationURL() {
671+
$auth_endpoint = $this->getProviderConfigValue('authorization_endpoint');
673672
$response_type = 'code';
674673

675674
// State essentially acts as a session key for OIDC
@@ -714,6 +713,16 @@ private function requestAuthorization() {
714713
}
715714

716715
$auth_endpoint .= (strpos($auth_endpoint, '?') === false ? '?' : '&') . http_build_query($auth_params, '', '&', $this->encType);
716+
return $auth_endpoint;
717+
}
718+
719+
/**
720+
* Start Here
721+
* @return void
722+
* @throws OpenIDConnectClientException
723+
*/
724+
private function requestAuthorization() {
725+
$auth_endpoint = $this->getAuthorizationURL();
717726

718727
$this->commitSession();
719728
$this->redirect($auth_endpoint);

0 commit comments

Comments
 (0)