Issues (29)

Controller/TestProviderController.php (2 issues)

1
<?php
2
App::uses('UniLoginUtil', 'UniLogin.Lib');
3
4
/**
5
 * TestProvider Controller.
6
 *
7
 */
8
class TestProviderController extends UniLoginAppController {
9
10
/**
11
 * Creates the redirect url based on query-parameter of configuration.
12
 *
13
 * @return mixed
14
 */
15
	protected function _getRedirectUrl() {
16
		$path = $this->request->query('path');
17
		$fingerprint = $this->request->query('auth');
18
		if ($path && $fingerprint) {
19
			$url = UniLoginUtil::decodeUrl($path);
20
			if (UniLoginUtil::validateUrlFingerprint($url, $fingerprint)) {
21
				$redirectUrl = $url;
22
			}
23
		}
24
25
		if (empty($redirectUrl)) {
26
			$redirectUrl = Configure::read('UniLogin.testProvider.defaultRedirectUrl');
0 ignored issues
show
The type Configure was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
		}
28
29
		return $redirectUrl;
30
	}
31
32
/**
33
 * Handles authentication requests.
34
 *
35
 * @return \Cake\Network\Response|null
0 ignored issues
show
The type Cake\Network\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
 */
37
	public function authenticate() {
38
		$applicationId = $this->request->query('id');
39
40
		$redirectUrl = $this->_getRedirectUrl();
41
42
		$timestamp = UniLoginUtil::getFormattedTimestamp();
43
		$user = Configure::read('UniLogin.testProvider.user');
44
		$auth = UniLoginUtil::calculateFingerprint($timestamp, $user);
45
46
		if (hash_equals((string)Configure::read('UniLogin.testProvider.applicationId'), (string)$applicationId)) {
47
			$query = [
48
				'user' => $user,
49
				'timestamp' => $timestamp,
50
				'auth' => $auth,
51
			];
52
			$redirectUrl .= '?' . http_build_query($query);
53
		}
54
55
		return $this->redirect($redirectUrl);
56
	}
57
}
58