thefunpower / flarum-ext-api-login
Create aes encode data for login
Installs: 39
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 1
Open Issues: 0
Type:flarum-extension
Requires
- flarum/core: ^1.2.0
- hamcq/filter-plus: ^1.0
- phpseclib/phpseclib: ^2.0
Requires (Dev)
- flarum/testing: ^1.0.0
README
Installation
Install with composer:
composer require thefunpower/flarum-ext-api-login:"*"
php flarum migrate
Updating
composer update thefunpower/flarum-ext-api-login:"*"
php flarum migrate
php flarum cache:clear
Setting
Create Aes Login Data
AesEncode
function
function flarum_aes_encode($data = [],$key,$iv){
$data = json_encode($data);
return @base64_encode(openssl_encrypt($data, 'AES-128-CBC', $key, 1, $iv));
}
Login
$flarum_url = 'http://127.0.0.1:5000';
$data = [
'nid'=>'third_user_id_1001',
'name'=>'admin',
'tag' =>'rand',
'created_at'=>time(),
];
$data = flarum_aes_encode($data);
$token = urlencode(base64_encode($data));
$url = $flarum_url.'/api/v2/login-token?token='.$token;
nid
|| name
must has one
using $url
in your iframe.
Register User Account
$flarum_url = 'http://127.0.0.1:5000';
$data = [
'nid'=>'third_user_id_1001',
'name'=>'admin',
'email'=>'admin@example.com',
'tag' =>'rand',
'created_at'=>time(),
];
$data = flarum_aes_encode($data);
$token = urlencode(base64_encode($data));
$url = $flarum_url.'/api/v2/login-token?token='.$token;
nid
is unique on third platform
Logout
/api/v2/logout