Download the PHP package adexos/m2-oauth2-league-bridge without Composer

On this page you can find all versions of the php package adexos/m2-oauth2-league-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package m2-oauth2-league-bridge

Adexos_Oauth2LeagueBridge

This module is intended to be a bridge client connection from OAuth 2 implementation for Magento 2.

Installation

You can install it by typing : composer require adexos/m2-oauth2-league-bridge

How to use ?

Create your own client extending the bridge one :

This class can be empty, it should only be created for the purpose of the di.xml.

Then you can add your own configuration in the di.xml :

The paths refer to your configuration. It's up to you to create your own system.xml depending on the path you give.

Optional : You can set the backend_model entry in your config.xml and system.xml as Magento\Config\Model\Config\Backend\Encrypted if you want to store your client secret in an encrypted way.

Example :

Here is a template as an example :

Please do not forget to create a config.xml as well.

Finally, you can use it this way :

Of course you need to update the grant_type and the options depending on your needs. The identifier set as a second parameter will be used to persist the token somewhere based on your configuration.

If you now want to retrieve your token and update it with the refresh token if it exists, you can simply call :

Cache systems

There is two major cache systems used in this module to store your OAuth tokens :

Session cache

This cache is especially useful to use with Identity tokens (login) that must be stored within the customer session data, here is how you can implement it :

Classic cache

It uses Magento native system, so you can use any cache that Magento supports : file, Redis or database.

This cache is more useful when you don't need to store the token for the current session but in a more global context such as a Management token.

Here is how you can implement it :

Please note that the cacheIdentifier will be used in the env.php file to determine how you are storing your tokens :

Database

env.php

Redis

env.php

/!\ Please use a specific database to the cache, do not use the same database as the session.

File

env.php

Cache lifetime

If you need to add a specific lifetime for the cache which is 1 hour by default, you can override in your di.xml the specificLifetime property :

Tags

Cache is regrouped by tags. You may want to specify tags to clean specific global area of the cache you created.

In the default configuration, the tag is : adx_oauth2_league_bridge

You can override it by updating your di.xml through the property tags :

You can add many tags you want.

Decoding the token

You can decode the token after you fetched it, it will also do the verification with the public key to ensure the integrity of the received token :

The jwtDecoder class is Adexos\Oauth2LeagueBridge\Decoder\JwtDecoder

As a second parameter of the decode method, you must pass a DTO implementing Adexos\Oauth2LeagueBridge\Decoder\Model\JwtResultInterface which is the content representation of the token. After that, you can manipulate the token result through an object and do whatever you want.

Alternative option provider (HttpBasicAuth/PostAuth)

The default option provider for the credentials concerning the access token is the PostAuthOptionProvider.

However, there are some systems when you need to instead use a HttpBasicAuthOptionProvider or even a custom one.

You simply need to add it in the di.xml of your client :

If you need to implement your own auth provider, simply create a class implementing League\OAuth2\Client\OptionProvider\OptionProviderInterface.


All versions of m2-oauth2-league-bridge with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.4
league/oauth2-client Version ^2.6
firebase/php-jwt Version ^6.0
symfony/serializer Version >=4.4
symfony/property-access Version >=4.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package adexos/m2-oauth2-league-bridge contains the following files

Loading the files please wait ....