Token authentication: Difference between revisions

From MiRTA PBX documentation
Jump to navigation Jump to search
Created page with "If you like to integrate MiRTA PBX in your portal and you like to have a single authentication, you can create a token with the username and password for the user and pass to the login.php script. <code><?php $key='*******'; $credentials['username']='*****'; $credentials['password']='*****'; $keyHash = hash('sha256', $key, true); $iv = substr($keyHash, 0, 16); define('AES_256_CBC', 'aes-256-cbc'); $token=base64_encode(openssl_encrypt(json_encode($credentials), AES_2..."
 
No edit summary
 
Line 1: Line 1:
If you like to integrate MiRTA PBX in your portal and you like to have a single authentication, you can create a token with the username and password for the user and pass to the login.php script.
If you like to integrate MiRTA PBX in your portal and you like to have a single authentication, you can create a token with the username and password for the user and pass to the login.php script.


<code><?php
  <?php
$key='*******';
  $key='*******';
 
 
$credentials['username']='*****';
  $credentials['username']='*****';
$credentials['password']='*****';
  $credentials['password']='*****';
 
 
$keyHash = hash('sha256', $key, true);
  $keyHash = hash('sha256', $key, true);
$iv = substr($keyHash, 0, 16);
  $iv = substr($keyHash, 0, 16);
 
 
define('AES_256_CBC', 'aes-256-cbc');
  define('AES_256_CBC', 'aes-256-cbc');
 
 
$token=base64_encode(openssl_encrypt(json_encode($credentials), AES_256_CBC, $keyHash, OPENSSL_RAW_DATA, $iv));
  $token=base64_encode(openssl_encrypt(json_encode($credentials), AES_256_CBC, $keyHash, OPENSSL_RAW_DATA, $iv));
 
 
$decoded=openssl_decrypt(base64_decode($token),AES_256_CBC,$keyHash,OPENSSL_RAW_DATA, $iv);
  $decoded=openssl_decrypt(base64_decode($token),AES_256_CBC,$keyHash,OPENSSL_RAW_DATA, $iv);
 
 
error_log($token);
  error_log($token);
error_log($decoded);
  error_log($decoded);
 
 
?></code>
  ?>


The generated token can be passed to the login.php via GET or POST as parameter token
The generated token can be passed to the login.php via GET or POST as parameter token


https://demo.mirtapbx.com/mirtapbx/login.php?token=IregEGKx5JyDV6y1Jugm3UBickltAKFovkmGINhMNxmXBmMU3IMxPGGhLcXfpRpQ
https://demo.mirtapbx.com/mirtapbx/login.php?token=IregEGKx5JyDV6y1Jugm3UBickltAKFovkmGINhMNxmXBmMU3IMxPGGhLcXfpRpQ

Latest revision as of 14:41, 3 August 2025

If you like to integrate MiRTA PBX in your portal and you like to have a single authentication, you can create a token with the username and password for the user and pass to the login.php script.

 <?php
 $key='*******';
 
 $credentials['username']='*****';
 $credentials['password']='*****';
 
 $keyHash = hash('sha256', $key, true);
 $iv = substr($keyHash, 0, 16);
 
 define('AES_256_CBC', 'aes-256-cbc');
 
 $token=base64_encode(openssl_encrypt(json_encode($credentials), AES_256_CBC, $keyHash, OPENSSL_RAW_DATA, $iv));
 
 $decoded=openssl_decrypt(base64_decode($token),AES_256_CBC,$keyHash,OPENSSL_RAW_DATA, $iv);
 
 error_log($token);
 error_log($decoded);
 
 ?>

The generated token can be passed to the login.php via GET or POST as parameter token

https://demo.mirtapbx.com/mirtapbx/login.php?token=IregEGKx5JyDV6y1Jugm3UBickltAKFovkmGINhMNxmXBmMU3IMxPGGhLcXfpRpQ