blobt
4 years ago
6 changed files with 64 additions and 183 deletions
-
18bin/server
-
10examples/client.php
-
41examples/jwt.php
-
162examples/rsa_test.php
-
2src/RpcServer.php
-
14systemd/airpc.service
@ -1,18 +0,0 @@ |
|||||
#!/usr/bin/env php |
|
||||
<?PHP |
|
||||
/* |
|
||||
* @Descripttion: |
|
||||
* @version: |
|
||||
* @Author: sueRimn |
|
||||
* @Date: 2020-07-30 09:48:18 |
|
||||
* @LastEditors: sueRimn |
|
||||
* @LastEditTime: 2020-07-30 14:20:19 |
|
||||
*/ |
|
||||
|
|
||||
include __DIR__."/../vendor/autoload.php"; |
|
||||
|
|
||||
use blobt\airpc\RpcServer; |
|
||||
|
|
||||
$server = new RpcServer("0.0.0.0", 5188); |
|
||||
$server->run(); |
|
||||
?> |
|
@ -0,0 +1,41 @@ |
|||||
|
<?php |
||||
|
include __DIR__ . "/../vendor/autoload.php"; |
||||
|
use \Firebase\JWT\JWT; |
||||
|
|
||||
|
$key = "example_key"; |
||||
|
$payload = array( |
||||
|
"iss" => "http://example.org", |
||||
|
"aud" => "http://example.com", |
||||
|
"iat" => 1356999524, |
||||
|
"nbf" => 1357000000 |
||||
|
); |
||||
|
|
||||
|
/** |
||||
|
* IMPORTANT: |
||||
|
* You must specify supported algorithms for your application. See |
||||
|
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40 |
||||
|
* for a list of spec-compliant algorithms. |
||||
|
*/ |
||||
|
echo $jwt = JWT::encode($payload, $key); |
||||
|
$decoded = JWT::decode($jwt, $key, array('HS256')); |
||||
|
|
||||
|
print_r($decoded); |
||||
|
|
||||
|
/* |
||||
|
NOTE: This will now be an object instead of an associative array. To get |
||||
|
an associative array, you will need to cast it as such: |
||||
|
*/ |
||||
|
|
||||
|
$decoded_array = (array) $decoded; |
||||
|
|
||||
|
/** |
||||
|
* You can add a leeway to account for when there is a clock skew times between |
||||
|
* the signing and verifying servers. It is recommended that this leeway should |
||||
|
* not be bigger than a few minutes. |
||||
|
* |
||||
|
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
|
||||
|
*/ |
||||
|
JWT::$leeway = 60; // $leeway in seconds
|
||||
|
$decoded = JWT::decode($jwt, $key, array('HS256')); |
||||
|
|
||||
|
?>
|
@ -0,0 +1,14 @@ |
|||||
|
[Unit] |
||||
|
Description=AI Rpc Server |
||||
|
After=network.target |
||||
|
After=syslog.target |
||||
|
|
||||
|
[Service] |
||||
|
Type=simple |
||||
|
LimitNOFILE=65535 |
||||
|
ExecStart=/usr/bin/php {your server path} |
||||
|
ExecReload=/bin/kill -USR1 $MAINPID |
||||
|
Restart=always |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=multi-user.target graphical.target |
Write
Preview
Loading…
Cancel
Save
Reference in new issue