33 #ifndef _IDENTT_HRPC_MASTER_ENDPOINT_SERVICE_HPP_ 34 #define _IDENTT_HRPC_MASTER_ENDPOINT_SERVICE_HPP_ 39 #include "store/InviteService.hpp" 40 #include "store/LookupService.hpp" 52 template <
class HttpServerT>
78 identt::utils::SharedTable::pointer stptr,
79 typename std::shared_ptr<HttpServerT> server,
80 ::identt::hrpc::RemoteKeeper::pointer rkeeper,
83 identt::query::
ServiceBase<HttpServerT>(IDENTT_SERVICE_SCOPE_HTTP | IDENTT_SERVICE_SCOPE_HTTPS)
85 if (!(this->myscope & scope))
return;
89 server->resource[
"/_identt/identity/master/v1/endpoint$"][
"POST"]
90 =[
this,stptr,rkeeper](
typename HttpServerT::RespPtr response,
typename HttpServerT::ReqPtr request) {
91 IDENTT_PARALLEL_ONE([
this,stptr,response,request] {
109 DLOG(INFO) << request->path;
113 case ::identt::hrpc::M_REQUESTTOKEN : {
114 identt::query::RequestTokenDataT data;
115 if (!data.ParseFromString( b64_decode(request->content.string()) ))
121 data.SerializeToString(&output);
122 DLOG(INFO) << request->path;
125 case ::identt::hrpc::M_SUBMITTOKEN : {
126 identt::query::SubmitTokenDataT data;
127 if (!data.ParseFromString( b64_decode(request->content.string()) ))
133 data.SerializeToString(&output);
134 DLOG(INFO) << request->path;
137 case ::identt::hrpc::M_GETVALIDATED3PID : {
138 identt::query::GetValidated3pidDataT data;
139 if (!data.ParseFromString( b64_decode(request->content.string()) ))
145 data.SerializeToString(&output);
146 DLOG(INFO) << request->path;
149 case ::identt::hrpc::M_BIND3PID : {
150 identt::query::Bind3pidDataT data;
151 if (!data.ParseFromString( b64_decode(request->content.string()) ))
157 data.SerializeToString(&output);
158 DLOG(INFO) << request->path;
161 case ::identt::hrpc::M_LOOKUP : {
162 identt::query::LookupDataT data;
163 if (!data.ParseFromString( b64_decode(request->content.string()) ))
169 data.SerializeToString(&output);
170 DLOG(INFO) << request->path;
173 case ::identt::hrpc::M_BULKLOOKUP : {
174 identt::query::BulkLookupDataT data;
175 if (!data.ParseFromString( b64_decode(request->content.string()) ))
181 data.SerializeToString(&output);
182 DLOG(INFO) << request->path;
185 case ::identt::hrpc::M_GETPUBKEY : {
186 identt::query::PubKeyT data;
187 if (!data.ParseFromString( b64_decode(request->content.string()) ))
193 data.SerializeToString(&output);
194 DLOG(INFO) << request->path;
197 case ::identt::hrpc::M_GETPUBKEYVALID : {
198 identt::query::PubKeyT data;
199 if (!data.ParseFromString( b64_decode(request->content.string()) ))
205 data.SerializeToString(&output);
206 DLOG(INFO) << request->path;
209 case ::identt::hrpc::M_GETEPHEMERALVALID : {
210 identt::query::PubKeyT data;
211 if (!data.ParseFromString( b64_decode(request->content.string()) ))
217 data.SerializeToString(&output);
218 DLOG(INFO) << request->path;
221 case ::identt::hrpc::M_STOREINVITE : {
222 identt::query::StoreInviteDataT data;
223 if (!data.ParseFromString( b64_decode(request->content.string()) ))
229 data.SerializeToString(&output);
230 DLOG(INFO) << request->path;
233 case ::identt::hrpc::M_PENDING : {
234 identt::mail::MailQueryT data;
235 if (!data.ParseFromString( b64_decode(request->content.string()) ))
241 data.SerializeToString(&output);
242 DLOG(INFO) << request->path;
245 case ::identt::hrpc::M_GETACCESSKEY : {
246 identt::query::GetAccessDataT data;
247 if (!data.ParseFromString( b64_decode(request->content.string()) ))
253 data.SerializeToString(&output);
254 DLOG(INFO) << request->path;
257 case ::identt::hrpc::M_SETBLOBDATA : {
258 identt::query::SetBlobDataT data;
259 if (!data.ParseFromString( b64_decode(request->content.string()) ))
265 data.SerializeToString(&output);
266 DLOG(INFO) << request->path;
269 case ::identt::hrpc::M_GETBLOBDATA : {
270 identt::query::GetBlobDataT data;
271 if (!data.ParseFromString( b64_decode(request->content.string()) ))
277 data.SerializeToString(&output);
278 DLOG(INFO) << request->path;
287 int ecode = (e.ecode()>=IDENTT_SYDENT_ERROR_MIN && e.ecode()<=IDENTT_SYDENT_ERROR_MAX) ? e.ecode() : M_UNKNOWN;
293 }
catch (std::exception& e)
300 output=
"Unknown Error";
318 #endif // _IDENTT_HRPC_MASTER_ENDPOINT_SERVICE_HPP_
void GetAccessKeyAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::GetAccessDataT *gva)
GetAccessKeyAction : get the access key.
Definition: BlobDataService.cc:50
void SetBlobDataAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::SetBlobDataT *bdata)
SetBlobDataAction : set the access key.
Definition: BlobDataService.cc:108
void Bind3pidAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::Bind3pidDataT *bpa)
Bind3pidAction: Bind a 3pid Request.
Definition: ThreePidService.cc:93
void GetValidated3pidAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::GetValidated3pidDataT *gva)
GetValidated3pidAction: Validate a 3pid Request.
Definition: ThreePidService.cc:58
void GetPubKeyValidAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::PubKeyT *pubkey)
GetPubKeyValidAction : Service Endpoint GetPubKeyValid.
Definition: PubKeyService.cc:58
Definition: ValidateService.hpp:42
void GetBlobDataAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::GetBlobDataT *bdata)
GetBlobDataAction : get the access key.
Definition: BlobDataService.cc:156
ServiceBase(const unsigned int myscope_)
Constructor : to be used by inherited classes.
Definition: ServiceBase.hpp:65
void ServiceOKAction(typename HttpServerT::RespPtr response, typename HttpServerT::ReqPtr request, std::string &payload)
ServiceOKAction : OK Action template for service.
Definition: ProtoServiceBase.hpp:114
Definition: BlobDataService.hpp:42
int ServiceName(typename HttpServerT::ReqPtr request)
ServiceName : Check protobuf request service name.
Definition: ProtoServiceBase.hpp:93
Sydent Exceptions.
Definition: SydentQuery.hpp:91
void GetPubKeyAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::PubKeyT *pubkey)
GetPubKeyAction : Service Endpoint GetPubKey.
Definition: PubKeyService.cc:43
void PendingAction(::identt::utils::SharedTable::pointer stptr, identt::mail::MailQueryT *mailq)
PendingAction : Get Pending as required.
Definition: MailSmsService.cc:46
Definition: HrpcMasterEndpointService.hpp:53
void SubmitTokenAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::SubmitTokenDataT *stoka)
SubmitTokenAction : Service Endpoint SubmitToken.
Definition: ValidateService.cc:154
void StoreInviteAction(::identt::utils::SharedTable::pointer stptr, identt::query::StoreInviteDataT *inv)
StoreInviteAction : invite query internals.
Definition: InviteService.cc:52
Definition: BaseUtils.hpp:52
Definition: PubKeyService.hpp:42
Definition: MailSmsService.hpp:42
Definition: ThreePidService.hpp:42
void GetEphemeralValidAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::PubKeyT *pubkey)
GetEphemeralValidAction : Service Endpoint GetEphemeralValid.
Definition: PubKeyService.cc:77
Definition: ServiceBase.hpp:55
Definition: CryptoBase.hpp:49
Definition: BaseUtils.hpp:89
void RequestTokenAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::RequestTokenDataT *rtoka)
RequestTokenAction : Service Endpoint RequestToken.
Definition: ValidateService.cc:47
bool SharedSecretOK(typename HttpServerT::ReqPtr request, std::string sharedkey)
SharedSecretOK : Check if shared key header is present and ok.
Definition: ProtoServiceBase.hpp:77
void BulkLookupAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::BulkLookupDataT *blact)
BulkLookupAction : Service Endpoint Lookup.
Definition: LookupService.cc:62
void ServiceErrAction(typename HttpServerT::RespPtr response, typename HttpServerT::ReqPtr request, int ecode, std::string &emsg)
ServiceErrAction : Error Action template for service.
Definition: ProtoServiceBase.hpp:173
Definition: ProtoServiceBase.hpp:43
Definition: LookupService.hpp:43
bool ProtoRequest(typename HttpServerT::ReqPtr request)
ProtoRequest : Check if request is protobuf from Content-Type and Accept fields.
Definition: ProtoServiceBase.hpp:55
HrpcMasterEndpointService(identt::utils::SharedTable::pointer stptr, typename std::shared_ptr< HttpServerT > server, ::identt::hrpc::RemoteKeeper::pointer rkeeper, unsigned int scope)
HrpcMasterEndpointService : constructor.
Definition: HrpcMasterEndpointService.hpp:77
void LookupAction(::identt::utils::SharedTable::pointer stptr, ::identt::query::LookupDataT *lact)
LookupAction : Service Endpoint Lookup.
Definition: LookupService.cc:47
Definition: InviteService.hpp:42