-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: composer dependencies * fix: bootstrap * fix: routes * fix: Application * fix: ProjectMiddleware * fix: beforeFilter and beforeRender signature * fix: enable login page view * fix: use EventInterface * test: use PHP 7.4, 8.0 and 8.1 * chore: aiax twig * feat: refactor helper method + test * fix: move flash templates * fix: use `do` * fix: flash paths * fix: handle view vars * fix: Url.build signature * chore: problematic `unlockField` commented (temp) * chore fix: make scrutinizer happy * chore fix: make scrutinizer happy * fix: Form.unlockField * fix: remove form from filter_box * fix: url.build and array default * chore: rename $builder to $routes * fix: `Cache` methods signatures * fix: '_serialize' var * chore: array safe check * fix: phpcs * fix: phpcs * refactor: update tests (#716) * refactor: update tests * fix: update tests * chore: git ignore * refactor: phpunit xml format * fix: middleware test * fix: remove unused import * chore: use web-tools 3.9 - PHP 8 * chore: remove PCOV clobber * fix: loadRoutes in tests * fix: setUp * fix: setUp * feat: loadRoutes in setUp in tests * fix: setUp * fix: setUp * fix: Auth tests * refactor: Plugin & LinkHelper classes * test: fix varioustests * chore: code style fixes * chore: cover method Co-authored-by: dante di domenico <dante@didoda.com> * chore: PHP version [ci skip] * chore: 3.0.0 version [ci skip] Co-authored-by: stefanorosanelli <stefano.rosanelli@gmail.com>
- Loading branch information
1 parent
8f9a13f
commit ecaee85
Showing
81 changed files
with
478 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[Manager] | ||
version = 2.2.1 | ||
version = 3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="./tests/bootstrap.php" | ||
> | ||
<php> | ||
<ini name="memory_limit" value="-1"/> | ||
<ini name="apc.enable_cli" value="1"/> | ||
</php> | ||
|
||
<!-- Add any additional test suites you want to run here --> | ||
<testsuites> | ||
<testsuite name="BEdita 4 Manager"> | ||
<directory>./tests/TestCase</directory> | ||
</testsuite> | ||
<!-- Add plugin test suites here. --> | ||
</testsuites> | ||
|
||
<!-- Setup a listener for fixtures --> | ||
<listeners> | ||
<listener | ||
class="\Cake\TestSuite\Fixture\FixtureInjector" | ||
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php"> | ||
<arguments> | ||
<object class="\Cake\TestSuite\Fixture\FixtureManager" /> | ||
</arguments> | ||
</listener> | ||
</listeners> | ||
|
||
<!-- Ignore vendor tests in code coverage reports --> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src/</directory> | ||
<exclude> | ||
<file>./src/Console/Installer.php</file> | ||
<file>./src/Shell/ConsoleShell.php</file> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src/</directory> | ||
</include> | ||
<exclude> | ||
<file>./src/Console/Installer.php</file> | ||
<file>./src/Shell/ConsoleShell.php</file> | ||
</exclude> | ||
</coverage> | ||
<php> | ||
<ini name="memory_limit" value="-1"/> | ||
<ini name="apc.enable_cli" value="1"/> | ||
</php> | ||
<!-- Add any additional test suites you want to run here --> | ||
<testsuites> | ||
<testsuite name="BEdita 4 Manager"> | ||
<directory>./tests/TestCase</directory> | ||
</testsuite> | ||
<!-- Add plugin test suites here. --> | ||
</testsuites> | ||
<!-- Setup a listener for fixtures --> | ||
<listeners> | ||
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php"> | ||
<arguments> | ||
<object class="\Cake\TestSuite\Fixture\FixtureManager"/> | ||
</arguments> | ||
</listener> | ||
</listeners> | ||
<!-- Ignore vendor tests in code coverage reports --> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* BEdita, API-first content management framework | ||
* Copyright 2018 ChannelWeb Srl, Chialab Srl | ||
* | ||
* This file is part of BEdita: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details. | ||
*/ | ||
|
||
namespace App\Auth; | ||
|
||
use BEdita\WebTools\ApiClientProvider; | ||
use Cake\Auth\BaseAuthenticate; | ||
use Cake\Http\Response; | ||
use Cake\Http\ServerRequest; | ||
use Cake\Utility\Hash; | ||
|
||
/** | ||
* An authentication adapter for authenticating using BEdita 4 API /auth endpoint. | ||
* | ||
* @see https://docs.bedita.net/en/latest/authorization.html#authentication | ||
*/ | ||
class ApiAuthenticate extends BaseAuthenticate | ||
{ | ||
/** | ||
* Default config for this object. | ||
* | ||
* - `fields` The fields to use to perform classic authentication. | ||
* | ||
* @var array | ||
*/ | ||
protected $_defaultConfig = [ | ||
'fields' => [ | ||
'username' => 'username', | ||
'password' => 'password', | ||
], | ||
]; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* Perform authentication via /auth | ||
*/ | ||
public function authenticate(ServerRequest $request, Response $response) | ||
{ | ||
/** @var \BEdita\SDK\BEditaClient $apiClient */ | ||
$apiClient = ApiClientProvider::getApiClient(); | ||
|
||
$usernameField = (string)$this->getConfig('fields.username', 'username'); | ||
$passwordField = (string)$this->getConfig('fields.password', 'password'); | ||
|
||
$result = $apiClient->authenticate((string)$request->getData($usernameField), (string)$request->getData($passwordField)); | ||
if (empty($result['meta'])) { | ||
return false; | ||
} | ||
|
||
$tokens = $result['meta']; | ||
$result = $apiClient->get('/auth/user', null, ['Authorization' => sprintf('Bearer %s', $tokens['jwt'])]); | ||
$roles = Hash::extract($result, 'included.{n}.attributes.name'); | ||
|
||
return $result['data'] + compact('tokens') + compact('roles'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.