mirror of
https://github.com/openvk/openvk
synced 2025-01-09 17:29:42 +03:00
ActivityPub: Add a Public PEM key, little fixes to the JSON Encoder
This commit is contained in:
parent
d1528a6355
commit
0c2a5b5eb7
4 changed files with 27 additions and 2 deletions
|
@ -42,7 +42,8 @@ ln -s /path/to/chandler/extensions/available/openvk /path/to/chandler/extensions
|
||||||
6. Copy `openvk-example.yml` to `openvk.yml` and change options
|
6. Copy `openvk-example.yml` to `openvk.yml` and change options
|
||||||
7. Run `composer install` in OpenVK directory
|
7. Run `composer install` in OpenVK directory
|
||||||
8. Move to `Web/static/js` and execute `yarn install`
|
8. Move to `Web/static/js` and execute `yarn install`
|
||||||
9. Set `openvk` as your root app in `chandler.yml`
|
9. Generate the private and public OpenSSL keys by running `openssl genrsa -out data/private.pem 2048` and `openssl rsa -in private.pem -outform PEM -pubout -out data/public.pem` in OpenVK directory
|
||||||
|
10. Set `openvk` as your root app in `chandler.yml`
|
||||||
|
|
||||||
Once you are done, you can login as a system administrator on the network itself (no registration required):
|
Once you are done, you can login as a system administrator on the network itself (no registration required):
|
||||||
* **Login**: `admin@localhost.localdomain6`
|
* **Login**: `admin@localhost.localdomain6`
|
||||||
|
|
|
@ -256,13 +256,15 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
|
|
||||||
protected function returnJson(array $json): void
|
protected function returnJson(array $json): void
|
||||||
{
|
{
|
||||||
$payload = json_encode($json);
|
$payload = json_encode($json, JSON_UNESCAPED_UNICODE);
|
||||||
$size = strlen($payload);
|
$size = strlen($payload);
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
header("Content-Length: $size");
|
header("Content-Length: $size");
|
||||||
exit($payload);
|
exit($payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ActivityPub quicks :DDD */
|
||||||
|
|
||||||
function isActivityPubClient(): bool
|
function isActivityPubClient(): bool
|
||||||
{
|
{
|
||||||
$accept = explode(";", $_SERVER['HTTP_ACCEPT']);
|
$accept = explode(";", $_SERVER['HTTP_ACCEPT']);
|
||||||
|
@ -304,4 +306,18 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
]');
|
]');
|
||||||
// Гришк)
|
// Гришк)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param private If true, it will return the private key. Otherwise, it will return the public key.
|
||||||
|
*/
|
||||||
|
function getKey(bool $private = false)
|
||||||
|
{
|
||||||
|
if(!file_exists(OPENVK_ROOT . ($private ? "/data/private.pem" : "/data/public.pem")))
|
||||||
|
throw new ISE("private.pem and public.pem files are missing. Please, check 10th step for a installation guide in README file.");
|
||||||
|
|
||||||
|
$key = file(OPENVK_ROOT . ($private ? "/data/private.pem" : "/data/public.pem"));
|
||||||
|
$key[0] = null;
|
||||||
|
$key[count($key)-1] = null;
|
||||||
|
return "-----BEGIN PUBLIC KEY-----\n" . str_replace("\n", '', implode('', $key)) . "\n-----END PUBLIC KEY-----\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,11 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
"inbox" => $user->getFullURL() . "/inbox",
|
"inbox" => $user->getFullURL() . "/inbox",
|
||||||
"outbox" => $user->getFullURL() . "/outbox",
|
"outbox" => $user->getFullURL() . "/outbox",
|
||||||
"endpoints" => array("sharedInbox" => ovk_scheme(true) . $_SERVER['SERVER_NAME']),
|
"endpoints" => array("sharedInbox" => ovk_scheme(true) . $_SERVER['SERVER_NAME']),
|
||||||
|
"publicKey" => array(
|
||||||
|
"id" => $user->getFullURL(true) . "#main-key",
|
||||||
|
"owner" => $user->getFullURL(true),
|
||||||
|
"publicKeyPem" => $this->getKey()
|
||||||
|
),
|
||||||
"wall" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $user->getId(),
|
"wall" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $user->getId(),
|
||||||
"firstName" => $user->getFirstName(),
|
"firstName" => $user->getFirstName(),
|
||||||
"lastName" => $user->getLastName(),
|
"lastName" => $user->getLastName(),
|
||||||
|
|
3
data/.gitignore
vendored
Executable file
3
data/.gitignore
vendored
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
private.pem
|
||||||
|
public.pem
|
||||||
|
knowledgebase/*
|
Loading…
Reference in a new issue