teknoo / east-common
Universal package, following the #East programming philosophy, build on Teknoo/East-Foundation (and Teknoo/Recipe), providing components (user management, object persistence, template rendering, ..) for the creation of web application or website.
Fund package maintenance!
Patreon
TeknooSoftware
Installs: 8 442
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.2
- php-di/php-di: ^7.0.6
- teknoo/east-foundation: ^8
- teknoo/immutable: ^3.0.18
- teknoo/recipe: ^6
- teknoo/states: ^6.4.1
Requires (Dev)
- ext-mongodb: *
- ext-tidy: *
- behat/behat: ^3.15
- doctrine/common: ^3.4.5
- doctrine/mongodb-odm: ^2.9
- doctrine/mongodb-odm-bundle: ^4.7||^5
- doctrine/persistence: ^3.4||^4
- knpuniversity/oauth2-client-bundle: ^2.18
- laminas/laminas-diactoros: ^3.5
- league/flysystem: ^3.29.1
- league/oauth2-client: ^2.7
- matthiasmullie/minify: ^1.3.73
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^1.12.7
- phpunit/phpunit: ^11.4.3
- roave/security-advisories: dev-latest
- scheb/2fa-backup-code: ^6.12||^7
- scheb/2fa-bundle: ^6.12||^7
- scheb/2fa-google-authenticator: ^6.12||^7
- scheb/2fa-totp: ^6.12||^7
- spomky-labs/otphp: ^11.2
- squizlabs/php_codesniffer: ^3.10.3
- symfony/config: ^6.3||^7
- symfony/console: ^6.3||^7
- symfony/dependency-injection: ^6.3||^7
- symfony/expression-language: ^6.3||^7
- symfony/form: ^6.3||^7
- symfony/http-kernel: ^6.3||^7
- symfony/mailer: ^6.3||^7
- symfony/mime: ^6.3||^7
- symfony/notifier: ^6.3||^7
- symfony/password-hasher: ^6.3||^7
- symfony/property-access: ^6.3||^7
- symfony/psr-http-message-bridge: ^2.3.1||^6.4||^7
- symfony/routing: ^6.3||^7
- symfony/security-bundle: ^6.3||^7
- symfony/security-core: ^6.3||^7
- symfony/security-http: ^6.3||^7
- symfony/validator: ^6.3||^7
- teknoo/bridge-phpdi-symfony: ^6.0.4
- twig/cssinliner-extra: ^3.13
- twig/inky-extra: ^3.13
- twig/twig: ^3.14
- dev-master
- 3.0.1
- 3.0.0
- 2.13.0
- 2.12.6
- 2.12.5
- 2.12.4
- 2.12.3
- 2.12.2
- 2.12.1
- 2.12.0
- 2.11.0
- 2.10.1
- 2.10.0
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.0
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.4.0-beta2
- 2.4.0-beta1
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 2.0.0-beta1
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
This package is auto-updated.
Last update: 2024-11-06 22:19:13 UTC
README
Universal package, following the #East programming philosophy, build on Teknoo/East-Foundation (and Teknoo/Recipe), and providing components (user management, object persistence, template rendering, ..) for the creation of web application or website.
This project is a fork of East Website
to separate the CMS (admin, front and translation) and all others base
components helpful to build a website or a webapp (objet persistence and CRUD operations, template rendering, user
management and authentification).
Example with Symfony
#These operations are not required with teknoo/east-common-symfony #config/packages/di_bridge.yaml: di_bridge: compilation_path: '%kernel.project_dir%/var/cache/phpdi' definitions: - '%kernel.project_dir%/config/di.php' #config/packages/east_foundation.yaml: di_bridge: definitions: - '%kernel.project_dir%/vendor/teknoo/east-foundation/src/di.php' - '%kernel.project_dir%/vendor/teknoo/east-foundation/infrastructures/symfony/Resources/config/di.php' - '%kernel.project_dir%/vendor/teknoo/east-foundation/infrastructures/symfony/Resources/config/laminas_di.php' import: Psr\Log\LoggerInterface: 'logger' #config/packages/east_common_di.yaml: di_bridge: definitions: - '%kernel.project_dir%/vendor/teknoo/east-common/src/di.php' - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/di.php' - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/symfony/Resources/config/di.php' - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/symfony/Resources/config/laminas_di.php' - '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/di.php' import: Doctrine\Persistence\ObjectManager: 'doctrine_mongodb.odm.default_document_manager' #bundles.php ... Teknoo\DI\SymfonyBridge\DIBridgeBundle::class => ['all' => true], Teknoo\East\FoundationBundle\EastFoundationBundle::class => ['all' => true], Teknoo\East\CommonBundle\TeknooEastCommonBundle::class => ['all' => true], #In doctrine config (east_common_doctrine_mongodb.yaml) doctrine_mongodb: document_managers: default: auto_mapping: true mappings: TeknooEastCommon: type: 'xml' dir: '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/config/universal' is_bundle: false prefix: 'Teknoo\East\Common\Object' TeknooEastCommonDoctrine: type: 'xml' dir: '%kernel.project_dir%/vendor/teknoo/east-common/infrastructures/doctrine/config/doctrine' is_bundle: false prefix: 'Teknoo\East\Common\Doctrine\Object' #In security.yaml security: #... providers: with_password: id: 'Teknoo\East\CommonBundle\Provider\PasswordAuthenticatedUserProvider' password_hashers: Teknoo\East\CommonBundle\Object\PasswordAuthenticatedUser: algorithm: '%teknoo.east.common.bundle.password_authenticated_user_provider.default_algo%' #In routes/common.yaml admin_common: resource: '@TeknooEastCommonBundle/Resources/config/admin_routing.yaml' prefix: '/admin' common: resource: '@TeknooEastCommonBundle/Resources/config/routing.yaml'
Enable third party authentication with an OAuth2 Provider (example with Gitlab)
//In security.yaml security: providers: //... # Third party user provider from_third_party: id: 'Teknoo\East\CommonBundle\Provider\ThirdPartyAuthenticatedUserProvider' firewalls: # disables authentication for assets and the profiler, adapt it according to your needs //... admin_gitlab_login: pattern: '^/oauth2/gitlab/login$' security: false #require admin role for all others pages restricted_area: //... # Enable oauth2 authenticator for this form custom_authenticators: - '%teknoo.east.common.bundle.security.authenticator.oauth2.class%' //In knpu_oauth2_client.yaml knpu_oauth2_client: clients: # will create service: "knpu.oauth2.client.gitlab" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\GitlabClient # composer require omines/oauth2-gitlab gitlab: # must be "gitlab" - it activates that type! type: gitlab # add and set these environment variables in your .env files client_id: '%env(OAUTH_GITLAB_CLIENT_ID)%' client_secret: '%env(OAUTH_GITLAB_CLIENT_SECRET)%' # a route name you'll create redirect_route: admin_connect_gitlab_check redirect_params: {} # Base installation URL, modify this for self-hosted instances domain: '%env(OAUTH_GITLAB_URL)%' //In service.yaml services: Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint: class: 'Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint' arguments: - '@KnpU\OAuth2ClientBundle\Client\ClientRegistry' - 'gitlab' - ['read_user'] calls: - ['setResponseFactory', ['@Psr\Http\Message\ResponseFactoryInterface']] - ['setRouter', ['@router']] public: true Teknoo\East\CommonBundle\Contracts\Security\Authenticator\UserConverterInterface: class: 'App\Security\Authenticator\UserConverter'
//In src/Security\Authenticator\UserConverter.php <?php declare(strict_types=1); namespace App\Security\Authenticator; use DomainException; use League\OAuth2\Client\Provider\ResourceOwnerInterface; use Omines\OAuth2\Client\Provider\GitlabResourceOwner; use Teknoo\East\Common\Object\User; use Teknoo\East\CommonBundle\Contracts\Security\Authenticator\UserConverterInterface; use Teknoo\Recipe\Promise\PromiseInterface; class UserConverter implements UserConverterInterface { public function extractEmail(ResourceOwnerInterface $owner, PromiseInterface $promise): UserConverterInterface { if (!$owner instanceof GitlabResourceOwner) { $promise->fail(new DomainException('Resource not manager')); return $this; } $promise->success($owner->getEmail()); return $this; } public function convertToUser(ResourceOwnerInterface $owner, PromiseInterface $promise): UserConverterInterface { if (!$owner instanceof GitlabResourceOwner) { $promise->fail(new DomainException('Resource not manager')); return $this; } $promise->success( (new User())->setEmail($owner->getEmail()) ->setLastName($owner->getName()) ->setFirstName($owner->getUsername()) ); return $this; } }
//In routes/gitlab.yaml admin_connect_gitlab_login: path: '/oauth2/gitlab/login' defaults: _controller: 'Teknoo\East\CommonBundle\EndPoint\ConnectEndPoint' admin_connect_gitlab_check: path: '/oauth2/gitlab/check' defaults: _controller: 'teknoo.east.common.endpoint.static' template: '@@TeknooEastCommon/Admin/index.html.twig' errorTemplate: '@@TeknooEastCommon/Error/404.html.twig' _oauth_client_key: gitlab
//In your template, create a link with {{ path('admin_connect_gitlab_login') }}
Support this project
This project is free and will remain free. It is fully supported by the activities of the EIRL. If you like it and help me maintain it and evolve it, don't hesitate to support me on Patreon or Github.
Thanks :) Richard.
Credits
EIRL Richard Déloge - https://deloge.io - Lead developer. SASU Teknoo Software - https://teknoo.software
About Teknoo Software
Teknoo Software is a PHP software editor, founded by Richard Déloge, as part of EIRL Richard Déloge. Teknoo Software's goals : Provide to our partners and to the community a set of high quality services or software, sharing knowledge and skills.
License
East Common is licensed under the MIT License - see the licenses folder for details.
Installation & Requirements
To install this library with composer, run this command :
composer require teknoo/east-common
To start a project with Symfony :
symfony new your_project_name new
composer require teknoo/composer-install
composer require teknoo/east-common-symfony
This library requires :
* PHP 8.1+
* A PHP autoloader (Composer is recommended)
* Teknoo/Immutable.
* Teknoo/States.
* Teknoo/Recipe.
* Teknoo/East-Foundation.
* Optional: Symfony 6.3+ (for administration)
News from Teknoo Common
This library requires PHP 8.1 or newer and it's only compatible with Symfony 6.0 or newer.
- Support Recipe 4.1.1+
- Support East Foundation 6.0.1+
- Public constant are final
- Block's types are Enums
- Direction are Enums
- Use readonly properties behaviors on Immutables
- Remove support of deprecated features removed in
Symfony 6.0
(Salt
,LegacyUser
) - Use
(...)
notation instead array notation for callable - Enable fiber support in front endpoint
QueryInterface
has been splitted toQueryElementInterface
andQueryCollectionInterface
to differentiate queries fetching only one element, or a scalar value, and queries for collections of objects.LoaderInterface::query
method is only dedicated forQueryCollectionInterface
queries.- a new method
LoaderInterface::fetch
is dedicated forQueryElementInterface
queries.
- Warning * : All legacy user are not supported from this version. User's salt are also not supported, all users' passwords must be converted before switching to this version.
Contribute :)
You are welcome to contribute to this project. Fork it on Github