mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 00:15:51 -04:00
Implement JSON API HTTP Basic authentication
jsonapi-generator is now capable of generating API for headers outside retroshare/ directory jsonapi-generator do a bit of methods parameter sanity check JsonApiServer is now integrated in the rsinit hell like other services Add *::exportGPGKeyPairToString to a bunch of classes in cascade RsControl is now capable of calling back a function when retroshare is almost completely stopped, this is useful when running retroshare toghether with externally managed runloop such as QCoreApplication Expose a bunch of methods through JSON API retroshare-nogui remove some dead code and fix stopping from the RetroShare API
This commit is contained in:
parent
ac9350d375
commit
eb77f921ec
32 changed files with 816 additions and 398 deletions
69
libretroshare/src/jsonapi/jsonapiitems.h
Normal file
69
libretroshare/src/jsonapi/jsonapiitems.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* RetroShare JSON API
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
#include "rsitems/rsitem.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "serialiser/rsserializer.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
|
||||
enum class JsonApiItemsType : uint8_t { AuthTokenItem = 0 };
|
||||
|
||||
struct JsonApiServerAuthTokenStorage : RsItem
|
||||
{
|
||||
JsonApiServerAuthTokenStorage() :
|
||||
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_JSONAPI,
|
||||
static_cast<uint8_t>(JsonApiItemsType::AuthTokenItem) ) {}
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RS_SERIAL_PROCESS(mAuthorizedTokens);
|
||||
}
|
||||
|
||||
/// @see RsItem
|
||||
virtual void clear() { mAuthorizedTokens.clear(); }
|
||||
|
||||
std::set<std::string> mAuthorizedTokens;
|
||||
};
|
||||
|
||||
|
||||
struct JsonApiConfigSerializer : RsServiceSerializer
|
||||
{
|
||||
JsonApiConfigSerializer() : RsServiceSerializer(RS_SERVICE_TYPE_JSONAPI) {}
|
||||
virtual ~JsonApiConfigSerializer() {}
|
||||
|
||||
RsItem* create_item(uint16_t service_id, uint8_t item_sub_id) const
|
||||
{
|
||||
if(service_id != RS_SERVICE_TYPE_JSONAPI) return nullptr;
|
||||
|
||||
switch(static_cast<JsonApiItemsType>(item_sub_id))
|
||||
{
|
||||
case JsonApiItemsType::AuthTokenItem: return new JsonApiServerAuthTokenStorage();
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue