Skip to content

Commit

Permalink
Fix URL building when cas_url setting have leading space
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
jajm committed Jun 23, 2022
1 parent bc15e54 commit 1f22f25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Fixed URL building when `cas_url` setting have leading space (#1)

## [0.4.1] - 2022-05-09

### Fixed
Expand Down
9 changes: 7 additions & 2 deletions src/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function loginAction ()
$session->offsetSet('redirect_url', $redirectUrl);
}

$casUrl = UriFactory::factory(sprintf('%s/login', $this->settings()->get('cas_url')));
$casUrl = UriFactory::factory(sprintf('%s/login', $this->getCasUrlSetting()));
$query = [
'service' => $this->getServiceUrl(),
];
Expand Down Expand Up @@ -115,7 +115,7 @@ public function validateAction()

protected function serviceValidate($ticket)
{
$serviceValidateUrl = $this->settings()->get('cas_url') . '/serviceValidate';
$serviceValidateUrl = $this->getCasUrlSetting() . '/serviceValidate';
$httpClient = $this->httpClient;
$httpClient->reset();
$httpClient->setUri($serviceValidateUrl);
Expand Down Expand Up @@ -210,4 +210,9 @@ protected function getServiceUrl()
{
return $this->url()->fromRoute('cas/validate', [], ['force_canonical' => true]);
}

protected function getCasUrlSetting()
{
return trim($this->settings()->get('cas_url'));
}
}

0 comments on commit 1f22f25

Please sign in to comment.