Passed
Pull Request — master (#1337)
by
unknown
06:32 queued 03:07
created
controller/Controller.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -46,45 +46,45 @@
 block discarded – undo
46 46
             $this->languages[$langcode]['lemma'] = Punic\Language::getName($langcode, $langcode);
47 47
         }
48 48
 
49
-		// Check if we have an authentication provider configured
50
-		// If so; check if the configured provider is actually a class we can use
51
-		if ( ( $authProvider = $this->model->getConfig()->getAuthenticationProvider() ) && class_exists( $authProvider ) ) {
52
-			$this->invokeAuthenticationLayer( new $authProvider($this) );
53
-		}
49
+    // Check if we have an authentication provider configured
50
+    // If so; check if the configured provider is actually a class we can use
51
+    if ( ( $authProvider = $this->model->getConfig()->getAuthenticationProvider() ) && class_exists( $authProvider ) ) {
52
+      $this->invokeAuthenticationLayer( new $authProvider($this) );
53
+    }
54 54
     }
55 55
 
56
-	/**
57
-	 * Invokes the authentication layer
58
-	 *
59
-	 * @param BaseAuthInterface $provider
60
-	 * @return void
61
-	 */
62
-	private function invokeAuthenticationLayer( BaseAuthInterface $authProvider ) {
63
-
64
-		// Validate the authentication provider's configuration parameters
65
-		if ( $authProvider->validate() ) {
66
-
67
-			// We don't have a valid user session; so sign in the user
68
-			if ( !$authProvider->isSignedIn() ) {
69
-				$authProvider->signIn();
70
-
71
-			// We have a valid session for this user; see if it wants to do anything..
72
-			} else if ( isset ( $_GET[ 'auth_do' ] ) ) {
73
-				$action = $_GET[ 'auth_do' ];
74
-
75
-				// Signout
76
-				if ( $action === 'signout' ) {
77
-					$authProvider->signOut();
78
-
79
-				// Retrieve user info
80
-				} else if ( $action === 'info' ) {
81
-					echo json_encode( $authProvider->getUserAttributes() );
82
-					$this->sendHeader('Content-Type: application/json' );
83
-					exit();
84
-				}
85
-			}
86
-		}
87
-	}
56
+  /**
57
+   * Invokes the authentication layer
58
+   *
59
+   * @param BaseAuthInterface $provider
60
+   * @return void
61
+   */
62
+  private function invokeAuthenticationLayer( BaseAuthInterface $authProvider ) {
63
+
64
+    // Validate the authentication provider's configuration parameters
65
+    if ( $authProvider->validate() ) {
66
+
67
+      // We don't have a valid user session; so sign in the user
68
+      if ( !$authProvider->isSignedIn() ) {
69
+        $authProvider->signIn();
70
+
71
+      // We have a valid session for this user; see if it wants to do anything..
72
+      } else if ( isset ( $_GET[ 'auth_do' ] ) ) {
73
+        $action = $_GET[ 'auth_do' ];
74
+
75
+        // Signout
76
+        if ( $action === 'signout' ) {
77
+          $authProvider->signOut();
78
+
79
+        // Retrieve user info
80
+        } else if ( $action === 'info' ) {
81
+          echo json_encode( $authProvider->getUserAttributes() );
82
+          $this->sendHeader('Content-Type: application/json' );
83
+          exit();
84
+        }
85
+      }
86
+    }
87
+  }
88 88
 
89 89
     /**
90 90
      * Sets the locale language properties from the parameter (used by gettext and some Model classes).
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 
49 49
 		// Check if we have an authentication provider configured
50 50
 		// If so; check if the configured provider is actually a class we can use
51
-		if ( ( $authProvider = $this->model->getConfig()->getAuthenticationProvider() ) && class_exists( $authProvider ) ) {
52
-			$this->invokeAuthenticationLayer( new $authProvider($this) );
51
+		if (($authProvider = $this->model->getConfig()->getAuthenticationProvider()) && class_exists($authProvider)) {
52
+			$this->invokeAuthenticationLayer(new $authProvider($this));
53 53
 		}
54 54
     }
55 55
 
@@ -59,27 +59,27 @@  discard block
 block discarded – undo
59 59
 	 * @param BaseAuthInterface $provider
60 60
 	 * @return void
61 61
 	 */
62
-	private function invokeAuthenticationLayer( BaseAuthInterface $authProvider ) {
62
+	private function invokeAuthenticationLayer(BaseAuthInterface $authProvider) {
63 63
 
64 64
 		// Validate the authentication provider's configuration parameters
65
-		if ( $authProvider->validate() ) {
65
+		if ($authProvider->validate()) {
66 66
 
67 67
 			// We don't have a valid user session; so sign in the user
68
-			if ( !$authProvider->isSignedIn() ) {
68
+			if (!$authProvider->isSignedIn()) {
69 69
 				$authProvider->signIn();
70 70
 
71 71
 			// We have a valid session for this user; see if it wants to do anything..
72
-			} else if ( isset ( $_GET[ 'auth_do' ] ) ) {
73
-				$action = $_GET[ 'auth_do' ];
72
+			} else if (isset ($_GET['auth_do'])) {
73
+				$action = $_GET['auth_do'];
74 74
 
75 75
 				// Signout
76
-				if ( $action === 'signout' ) {
76
+				if ($action === 'signout') {
77 77
 					$authProvider->signOut();
78 78
 
79 79
 				// Retrieve user info
80
-				} else if ( $action === 'info' ) {
81
-					echo json_encode( $authProvider->getUserAttributes() );
82
-					$this->sendHeader('Content-Type: application/json' );
80
+				} else if ($action === 'info') {
81
+					echo json_encode($authProvider->getUserAttributes());
82
+					$this->sendHeader('Content-Type: application/json');
83 83
 					exit();
84 84
 				}
85 85
 			}
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
         $localname = $vocab->getLocalName($uri);
196 196
         if ($localname !== $uri && $localname === urlencode($localname)) {
197 197
             // check that the prefix stripping worked, and there are no problematic chars in localname
198
-            $paramstr = count($params) > 0 ? '?' . http_build_query($params) : '';
198
+            $paramstr = count($params) > 0 ? '?'.http_build_query($params) : '';
199 199
             if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) {
200
-                return "$vocid/$lang/$type/$localname" . $paramstr;
200
+                return "$vocid/$lang/$type/$localname".$paramstr;
201 201
             }
202 202
 
203
-            return "$vocid/$lang/$localname" . $paramstr;
203
+            return "$vocid/$lang/$localname".$paramstr;
204 204
         }
205 205
 
206 206
         // case 2: URI outside vocabulary namespace, or has problematic chars
207 207
         // pass the full URI as parameter instead
208 208
         $params['uri'] = $uri;
209
-        return "$vocid/$lang/$type/?" . http_build_query($params);
209
+        return "$vocid/$lang/$type/?".http_build_query($params);
210 210
     }
211 211
 
212 212
     /**
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     {
333 333
         if ($modifiedDate) {
334 334
             $ifModifiedSince = $this->getIfModifiedSince();
335
-            $this->sendHeader("Last-Modified: " . $modifiedDate->format('D, d M Y H:i:s \G\M\T'));
335
+            $this->sendHeader("Last-Modified: ".$modifiedDate->format('D, d M Y H:i:s \G\M\T'));
336 336
             if ($ifModifiedSince !== null && $ifModifiedSince >= $modifiedDate) {
337 337
                 $this->sendHeader("HTTP/1.0 304 Not Modified");
338 338
                 return true;
Please login to merge, or discard this patch.
controller/Auth/BaseAuthInterface.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -2,45 +2,45 @@
 block discarded – undo
2 2
 
3 3
 interface BaseAuthInterface {
4 4
 
5
-	public function __construct( Controller $controller );
6
-
7
-	/**
8
-	 * Validate if all requirements are met to load this
9
-	 * authentication method. This function is useful for
10
-	 * validating configuration options inside Config.ttl.
11
-	 *
12
-	 * @return bool
13
-	 */
14
-	public function validate() :bool;
15
-
16
-	/**
17
-	 * Checks if the current user has a valid session on the
18
-	 * authorization endpoint.
19
-	 *
20
-	 * @return bool
21
-	 */
22
-	public function isSignedIn() : bool;
23
-
24
-	/**
25
-	 * Signs in the current user
26
-	 *
27
-	 * @return mixed
28
-	 */
29
-	public function signIn();
30
-
31
-	/**
32
-	 * Signs out the user
33
-	 *
34
-	 * @return mixed
35
-	 */
36
-	public function signOut();
37
-
38
-	/**
39
-	 * Retrieve the user's attributes
40
-	 *
41
-	 * @return array
42
-	 */
43
-	public function getUserAttributes() : array;
5
+  public function __construct( Controller $controller );
6
+
7
+  /**
8
+   * Validate if all requirements are met to load this
9
+   * authentication method. This function is useful for
10
+   * validating configuration options inside Config.ttl.
11
+   *
12
+   * @return bool
13
+   */
14
+  public function validate() :bool;
15
+
16
+  /**
17
+   * Checks if the current user has a valid session on the
18
+   * authorization endpoint.
19
+   *
20
+   * @return bool
21
+   */
22
+  public function isSignedIn() : bool;
23
+
24
+  /**
25
+   * Signs in the current user
26
+   *
27
+   * @return mixed
28
+   */
29
+  public function signIn();
30
+
31
+  /**
32
+   * Signs out the user
33
+   *
34
+   * @return mixed
35
+   */
36
+  public function signOut();
37
+
38
+  /**
39
+   * Retrieve the user's attributes
40
+   *
41
+   * @return array
42
+   */
43
+  public function getUserAttributes() : array;
44 44
 
45 45
 
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 interface BaseAuthInterface {
4 4
 
5
-	public function __construct( Controller $controller );
5
+	public function __construct(Controller $controller);
6 6
 
7 7
 	/**
8 8
 	 * Validate if all requirements are met to load this
Please login to merge, or discard this patch.
controller/Auth/SimpleSamlPHP/SimpleSamlPHP.php 2 patches
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -10,109 +10,109 @@
 block discarded – undo
10 10
  */
11 11
 class SimpleSamlPHP implements BaseAuthInterface {
12 12
 
13
-	/**
14
-	 * @var Model
15
-	 */
16
-	private $model;
17
-
18
-	/**
19
-	 * Placeholder of the SimpleSamlPHP authentication entity.
20
-	 *
21
-	 * @var string|null
22
-	 */
23
-	private $authEntity;
24
-
25
-	/**
26
-	 * The configured application URL
27
-	 *
28
-	 * @var string
29
-	 */
30
-	private $baseHref;
31
-
32
-	/**
33
-	 * @param Model $model
34
-	 */
35
-	public function __construct( Controller $controller ) {
36
-		$this->model = $controller->model;
37
-		$this->baseHref = $controller->getBaseHref();
38
-	}
39
-
40
-	/**
41
-	 * @inheritDoc
42
-	 */
43
-	public function validate(): bool {
44
-		$authDirectory = $this->model->getConfig()->getLiteral( 'skosmos:authProviderIncludeDirectory' );
45
-		if ( !$authDirectory ) {
46
-			return false;
47
-		}
48
-
49
-		$authEntity = $this->model->getConfig()->getLiteral( 'skosmos:authProviderAuthEntity' );
50
-		if ( !$authEntity ) {
51
-			return false;
52
-		} else {
53
-			$this->authEntity = $authEntity;
54
-		}
55
-
56
-		$sspAutoloader = $authDirectory . DIRECTORY_SEPARATOR . 'lib/_autoload.php';
57
-		if ( !file_exists( $sspAutoloader ) ) {
58
-			return false;
59
-		} else {
60
-			require $sspAutoloader;
61
-		}
62
-
63
-		return true;
64
-	}
65
-
66
-	/**
67
-	 * @inheritDoc
68
-	 */
69
-	public function isSignedIn(): bool {
70
-		return $this->getSessionFromRequest()->isValid( $this->authEntity );
71
-	}
72
-
73
-	/**
74
-	 * @inheritDoc
75
-	 */
76
-	public function signIn() {
77
-		$this->getAuthenticationSource()->requireAuth( [
78
-			'ReturnTo' => $this->baseHref
79
-		] );
80
-	}
81
-
82
-	/**
83
-	 * @inheritDoc
84
-	 */
85
-	public function signOut() {
86
-		$this->getAuthenticationSource()->logout( [
87
-			'ReturnTo' => $this->baseHref
88
-		] );
89
-	}
90
-
91
-	/**
92
-	 * @inheritDoc
93
-	 */
94
-	public function getUserAttributes(): array {
95
-		if ( $this->isSignedIn() ) {
96
-			return [];
97
-		}
98
-		return [
99
-			'auth_source' => $this->authEntity,
100
-			'attributes' => $this->getAuthenticationSource()->getAttributes()
101
-		];
102
-	}
103
-
104
-	/**
105
-	 * @return \SimpleSAML\Auth\Simple
106
-	 */
107
-	private function getAuthenticationSource( ) {
108
-		return new SimpleSAML\Auth\Simple( $this->authEntity );
109
-	}
110
-
111
-	/**
112
-	 * @return SimpleSAML\Session::getSessionFromRequest()
113
-	 */
114
-	private function getSessionFromRequest() {
115
-		return SimpleSAML\Session::getSessionFromRequest();
116
-	}
13
+  /**
14
+   * @var Model
15
+   */
16
+  private $model;
17
+
18
+  /**
19
+   * Placeholder of the SimpleSamlPHP authentication entity.
20
+   *
21
+   * @var string|null
22
+   */
23
+  private $authEntity;
24
+
25
+  /**
26
+   * The configured application URL
27
+   *
28
+   * @var string
29
+   */
30
+  private $baseHref;
31
+
32
+  /**
33
+   * @param Model $model
34
+   */
35
+  public function __construct( Controller $controller ) {
36
+    $this->model = $controller->model;
37
+    $this->baseHref = $controller->getBaseHref();
38
+  }
39
+
40
+  /**
41
+   * @inheritDoc
42
+   */
43
+  public function validate(): bool {
44
+    $authDirectory = $this->model->getConfig()->getLiteral( 'skosmos:authProviderIncludeDirectory' );
45
+    if ( !$authDirectory ) {
46
+      return false;
47
+    }
48
+
49
+    $authEntity = $this->model->getConfig()->getLiteral( 'skosmos:authProviderAuthEntity' );
50
+    if ( !$authEntity ) {
51
+      return false;
52
+    } else {
53
+      $this->authEntity = $authEntity;
54
+    }
55
+
56
+    $sspAutoloader = $authDirectory . DIRECTORY_SEPARATOR . 'lib/_autoload.php';
57
+    if ( !file_exists( $sspAutoloader ) ) {
58
+      return false;
59
+    } else {
60
+      require $sspAutoloader;
61
+    }
62
+
63
+    return true;
64
+  }
65
+
66
+  /**
67
+   * @inheritDoc
68
+   */
69
+  public function isSignedIn(): bool {
70
+    return $this->getSessionFromRequest()->isValid( $this->authEntity );
71
+  }
72
+
73
+  /**
74
+   * @inheritDoc
75
+   */
76
+  public function signIn() {
77
+    $this->getAuthenticationSource()->requireAuth( [
78
+      'ReturnTo' => $this->baseHref
79
+    ] );
80
+  }
81
+
82
+  /**
83
+   * @inheritDoc
84
+   */
85
+  public function signOut() {
86
+    $this->getAuthenticationSource()->logout( [
87
+      'ReturnTo' => $this->baseHref
88
+    ] );
89
+  }
90
+
91
+  /**
92
+   * @inheritDoc
93
+   */
94
+  public function getUserAttributes(): array {
95
+    if ( $this->isSignedIn() ) {
96
+      return [];
97
+    }
98
+    return [
99
+      'auth_source' => $this->authEntity,
100
+      'attributes' => $this->getAuthenticationSource()->getAttributes()
101
+    ];
102
+  }
103
+
104
+  /**
105
+   * @return \SimpleSAML\Auth\Simple
106
+   */
107
+  private function getAuthenticationSource( ) {
108
+    return new SimpleSAML\Auth\Simple( $this->authEntity );
109
+  }
110
+
111
+  /**
112
+   * @return SimpleSAML\Session::getSessionFromRequest()
113
+   */
114
+  private function getSessionFromRequest() {
115
+    return SimpleSAML\Session::getSessionFromRequest();
116
+  }
117 117
 
118 118
 }
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @param Model $model
34 34
 	 */
35
-	public function __construct( Controller $controller ) {
35
+	public function __construct(Controller $controller) {
36 36
 		$this->model = $controller->model;
37 37
 		$this->baseHref = $controller->getBaseHref();
38 38
 	}
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	 * @inheritDoc
42 42
 	 */
43 43
 	public function validate(): bool {
44
-		$authDirectory = $this->model->getConfig()->getLiteral( 'skosmos:authProviderIncludeDirectory' );
45
-		if ( !$authDirectory ) {
44
+		$authDirectory = $this->model->getConfig()->getLiteral('skosmos:authProviderIncludeDirectory');
45
+		if (!$authDirectory) {
46 46
 			return false;
47 47
 		}
48 48
 
49
-		$authEntity = $this->model->getConfig()->getLiteral( 'skosmos:authProviderAuthEntity' );
50
-		if ( !$authEntity ) {
49
+		$authEntity = $this->model->getConfig()->getLiteral('skosmos:authProviderAuthEntity');
50
+		if (!$authEntity) {
51 51
 			return false;
52 52
 		} else {
53 53
 			$this->authEntity = $authEntity;
54 54
 		}
55 55
 
56
-		$sspAutoloader = $authDirectory . DIRECTORY_SEPARATOR . 'lib/_autoload.php';
57
-		if ( !file_exists( $sspAutoloader ) ) {
56
+		$sspAutoloader = $authDirectory.DIRECTORY_SEPARATOR.'lib/_autoload.php';
57
+		if (!file_exists($sspAutoloader)) {
58 58
 			return false;
59 59
 		} else {
60 60
 			require $sspAutoloader;
@@ -67,32 +67,32 @@  discard block
 block discarded – undo
67 67
 	 * @inheritDoc
68 68
 	 */
69 69
 	public function isSignedIn(): bool {
70
-		return $this->getSessionFromRequest()->isValid( $this->authEntity );
70
+		return $this->getSessionFromRequest()->isValid($this->authEntity);
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * @inheritDoc
75 75
 	 */
76 76
 	public function signIn() {
77
-		$this->getAuthenticationSource()->requireAuth( [
77
+		$this->getAuthenticationSource()->requireAuth([
78 78
 			'ReturnTo' => $this->baseHref
79
-		] );
79
+		]);
80 80
 	}
81 81
 
82 82
 	/**
83 83
 	 * @inheritDoc
84 84
 	 */
85 85
 	public function signOut() {
86
-		$this->getAuthenticationSource()->logout( [
86
+		$this->getAuthenticationSource()->logout([
87 87
 			'ReturnTo' => $this->baseHref
88
-		] );
88
+		]);
89 89
 	}
90 90
 
91 91
 	/**
92 92
 	 * @inheritDoc
93 93
 	 */
94 94
 	public function getUserAttributes(): array {
95
-		if ( $this->isSignedIn() ) {
95
+		if ($this->isSignedIn()) {
96 96
 			return [];
97 97
 		}
98 98
 		return [
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @return \SimpleSAML\Auth\Simple
106 106
 	 */
107 107
 	private function getAuthenticationSource( ) {
108
-		return new SimpleSAML\Auth\Simple( $this->authEntity );
108
+		return new SimpleSAML\Auth\Simple($this->authEntity);
109 109
 	}
110 110
 
111 111
 	/**
Please login to merge, or discard this patch.
model/GlobalConfig.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -361,10 +361,10 @@
 block discarded – undo
361 361
         return $this->getBoolean('skosmos:sparqlCollationEnabled', FALSE);
362 362
     }
363 363
 
364
-	/**
365
-	 * @return string|null
366
-	 */
367
-	public function getAuthenticationProvider() {
368
-		return $this->getLiteral('skosmos:authenticationProvider', false);
369
-	}
364
+  /**
365
+   * @return string|null
366
+   */
367
+  public function getAuthenticationProvider() {
368
+    return $this->getLiteral('skosmos:authenticationProvider', false);
369
+  }
370 370
 }
Please login to merge, or discard this patch.
model/BaseConfig.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
 abstract class BaseConfig extends DataObject
8 8
 {
9 9
 
10
-	/**
11
-     * Returns a boolean value based on a literal value from the config.ttl configuration.
12
-     * @param string $property the property to query
13
-     * @param boolean $default the default value if the value is not set in configuration
14
-     * @return boolean the boolean value for the given property, or the default value if not found
15
-     */
10
+  /**
11
+   * Returns a boolean value based on a literal value from the config.ttl configuration.
12
+   * @param string $property the property to query
13
+   * @param boolean $default the default value if the value is not set in configuration
14
+   * @return boolean the boolean value for the given property, or the default value if not found
15
+   */
16 16
     public function getBoolean($property, $default = false)
17 17
     {
18 18
         $val = $this->getResource()->getLiteral($property);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
      * @param string $lang preferred language for the literal
45 45
      * @return string string value for the given property, or the default value if not found
46 46
      */
47
-    public function getLiteral($property, $default=null, $lang=null)
47
+    public function getLiteral($property, $default = null, $lang = null)
48 48
     {
49 49
         if (!isset($lang)) {
50 50
             $lang = $this->getEnvLang();
Please login to merge, or discard this patch.