summaryrefslogtreecommitdiff
path: root/app/Core/Security/Authorization.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-11-27 16:24:21 -0500
committerFrederic Guillot <fred@kanboard.net>2015-11-27 16:24:21 -0500
commit91bdf6aaf3cda52a43c35ce22f5e25537684cb56 (patch)
tree567631b186191508d7cc40f914ffe83740f0d355 /app/Core/Security/Authorization.php
parent19706944dc94c4fe1784af434f5f2e27a3c8130c (diff)
Add generic authorization class
Diffstat (limited to 'app/Core/Security/Authorization.php')
-rw-r--r--app/Core/Security/Authorization.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/Core/Security/Authorization.php b/app/Core/Security/Authorization.php
new file mode 100644
index 00000000..a04b3720
--- /dev/null
+++ b/app/Core/Security/Authorization.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Kanboard\Core\Security;
+
+/**
+ * Authorization Handler
+ *
+ * @package security
+ * @author Frederic Guillot
+ */
+class Authorization
+{
+ /**
+ * Access Map
+ *
+ * @access private
+ * @var AccessMap
+ */
+ private $acl;
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param AccessMap $acl
+ */
+ public function __construct(AccessMap $acl)
+ {
+ $this->acl = $acl;
+ }
+
+ /**
+ * Check if the given role is allowed to access to the specified resource
+ *
+ * @access public
+ * @param string $controller
+ * @param string $method
+ * @param string $role
+ * @return boolean
+ */
+ public function isAllowed($controller, $method, $role)
+ {
+ $roles = $this->acl->getRoles($controller, $method);
+ return in_array($role, $roles);
+ }
+}