Download the PHP package verzth/tcx without Composer
On this page you can find all versions of the php package verzth/tcx. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tcx
TCX v4.0.0 - Authentication Module for Client-Server Transaction (One Way - Two Way).
TCX is authentication module to secure API Server.
It's adapt OAuth2 scheme, but it use more simplify scheme which provide authentication for client-server without need to define scopes.
Dependencies
Laravel >= 5.6
How to Install
How to Use
-
Add our ServiceProvider on your config/app.php.
-
Add TCX Middleware in your app/Http/Kernel.php.
- In every request.
or
- In your API group middleware only.
or
- In your route middleware, and you can add manually on your route.
-
Publish our vendor with artisan command.
-
Migrate our TCX DB. After migrate it, you will get 3 tables (tcx_applications, tcx_accesses, tcx_mkas).
-
Refresh the autoload with below command.
-
We provide seeder to generate sample data. Simply put below code to file database/seeds/DatabaseSeeder.php, inside run() function.
then run below script on your shell/command prompt.
- Or just run below script (skip step 6) to generate the sample data.
Implementation
-
Authentication Type, TCX support three ways authentication type:
- One Way Transaction Code (OWTC): Client only need to use app_id and app_public to access Server APIs.
- Two Way Transaction Code (TWTC): Client has to use app_id and app_public to get access token, then it can be used to access APIs.
- Free Transaction Code (FTC): Client use master token to access APIs, without need to request token for every requests, it's specially design to by pass TWTC authentication. You need to generate Master token manually.
To specify authentication for each APIs assign parameter in the middleware, use or (|) sign to specify multiple authentication or use all to support all type (Supported type : all, owtc, twtc). By default, TCX will support all authentication if you didn't specifying supported type.
Client need to specify type by sending X-TCX-TYPE header in every APIs request.
-
How to generate credentials:
-
app_pass or X-TCX-APP-PASS, it can be generate by hashing plain of joined token (param, time, or none), application public key, and client dynamic token with SHA1. Client need to append the given dynamic token to hash result by splitting with colon (:) symbol, then encrypt it with base64.
-
Param base
Sample Parameter:
Expected Token:
- Time base
Sample
- None, just using application password and client dynamic token.
-
- token or X-TCX-TOKEN, it's provided when Client authorizing to server, but you need to encrypt it with base64.
-
-
Authentication Headers.
- Type OWTC:
- 'X-TCX-TYPE': 'OWTC'.
- 'X-TCX-APP-ID': Client ID.
- 'X-TCX-APP-PASS': Client Password.
- Type TWTC:
- 'X-TCX-TYPE': 'TWTC'.
- 'X-TCX-APP-ID': Client ID.
- 'X-TCX-APP-PASS': Client Password.
- 'X-TCX-TOKEN': Access Token, obtained by doing authorization.
- Type FTC:
- 'X-TCX-TYPE': 'FTC'.
- 'X-TCX-APP-ID': Client ID.
- 'X-TCX-APP-PASS': Client Password.
- 'X-TCX-TOKEN': Master Access Token.
- Type OWTC:
-
Authorization Routes, TCX provide some routes which is can be used to get access token in TWTC type:
-
/tcx/authorize:
- METHOD: POST
- Params:
- app_id: Client application id.
- app_pass: Client password.
Sample Fail response
Sample Success response
-
/tcx/reauthorize:
Refresh token can be used to refresh your existing token, you can pass it to this service and your existing token will be extended. Service will reply new refresh token for your existing token to be used in next refresh.
- METHOD: POST
- Params:
- app_id: Client application id.
- token: Refresh Token.
Sample Fail response
Sample Success response
-
-
Response Status.
Status Number Code Message Note 0 70FF000 TCXREQ TCX Authentication Required Provide Authentication Header 0 20FF001 TCXRJC TCX Authentication Rejected X-TCX-Type not supported or disabled 0 40FF002 TCXAFX TCX Authentication Failed X-TCX-App-ID not found, invalid, or inactive 0 50FF003 TCXPFX TCX Pass did not match X-TCX-App-Pass not passed, crosscheck point 2 0 50FF004 TCXMKF TCX Master Key did not valid Check the master access key (Only FTC) 0 50FF005 TCXTFX TCX Token did not valid Check the access key (Only TWTC) Sample Response:
All versions of tcx with dependencies
illuminate/support Version ^5.6|^6.0|^7.0
illuminate/http Version ^5.6|^6.0|^7.0
illuminate/database Version ^5.6|^6.0|^7.0
illuminate/routing Version ^5.6|^6.0|^7.0
symfony/http-foundation Version ^4|^5.0
symfony/http-kernel Version ^4|^5.0