Api Token Login
This extend is for your web system to login flarum using token.
Sometimes when we login our system then sync login state to flarum,this extends easy to sync login state to flarum.
- install
composer require thefunpower/flarum-ext-api-login
php flarum migrate
upgrade
composer update thefunpower/flarum-ext-api-login
php flarum migrate
- active extend
- setting aes key 、aes iv 、rand string
in your system (not the flarum),
function flarum_aes_encode($data = [],$key,$iv){
$data = json_encode($data);
return @base64_encode(openssl_encrypt($data, 'AES-128-CBC', $key, 1, $iv));
}
$flarum_url = 'http://127.0.0.1:5000';
$data = [
'nid'=>'third_user_id_1001',
'name'=>'admin',
'tag' =>'rand', // should be the same as setting rand string
'created_at'=>time(),
];
$key = ''; // should be the same as setting aes key
$iv = ''; // should be the same as setting aes iv
$data = flarum_aes_encode($data,$key,$iv);
$token = urlencode(base64_encode($data));
$url = $flarum_url.'/api/v2/login-token?token='.$token;
// $url your can jump this url ,or add it in your iframe.
github
packages