Skip to content

Commit

Permalink
Add a configuration to use custom URL validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
erozqba committed Dec 15, 2016
1 parent a24cfd1 commit 7c57f50
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Xavrsl/Cas/Sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ private function initializeCas()
$this->configureCasClient();

$this->configureSslValidation();
$this->configureServerValidateURL();
phpCAS::handleLogoutRequests();

$this->configureProxyChain();
Expand Down Expand Up @@ -99,6 +100,27 @@ private function configureSslValidation()
}
}

/**
* Configure Server Validate URL
*
* Override the validation URL is sometimes wanted.
*/
private function configureServerValidateURL()
{
// override validation URL for the CAS server
if ($this->config['cas_validation_url'])
{
if ($this->config['cas_saml'])
{
phpCAS::setServerSamlValidateURL($this->config['cas_validation_url']);
}
else
{
phpCAS::setServerServiceValidateURL($this->config['cas_validation_url']);
}
}
}

/**
* Configure Cas Proxy Chain
*
Expand Down Expand Up @@ -218,6 +240,8 @@ public function user()
*/
public function getAttributes()
{
if($this->isPretending()) return $this->config['cas_pretend_user_attributes'];

return phpCAS::getAttributes();
}

Expand Down
29 changes: 29 additions & 0 deletions src/config/cas.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
'cas_validation' => env('CAS_VALIDATION', ''),


/*
|--------------------------------------------------------------------------
| Custom CAS Validation URL
|--------------------------------------------------------------------------
|
| Custom CAS server URL validation: In general the validation URL is in the same
| server and we don't need to provide this URL, but in some cases we can
| or need to provide a custom URL validation.
|
*/

'cas_validation_url' => env('CAS_VALIDATION_URL', false),


/*
|--------------------------------------------------------------------------
| CAS Certificate
Expand All @@ -87,6 +101,21 @@

'cas_pretend_user' => env('CAS_PRETEND_USER', ''),


/*
|--------------------------------------------------------------------------
| Pretend CAS user attributes
|--------------------------------------------------------------------------
|
| This is useful in development mode. CAS is not called at all, only user
| is set and the attributes are returned if ::getAttributes() is called.
|
| For the exemple:
| 'cas_pretend_user_attributes' => array('role' => 'ADMIN'),
*/

'cas_pretend_user_attributes' => array(),

/*
|--------------------------------------------------------------------------
| Use as Cas proxy ?
Expand Down

0 comments on commit 7c57f50

Please sign in to comment.