From 7e8f3048d31afe4aa803d160fe915e3dae397c41 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 18 Feb 2019 10:28:09 -0800 Subject: [PATCH] modules: Start and identity service stub area. --- modules/Makefile.am | 15 ++++++++ modules/identity/pubkey.cc | 77 ++++++++++++++++++++++++++++++++++++++ modules/identity/v1.cc | 43 +++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 modules/identity/pubkey.cc create mode 100644 modules/identity/v1.cc diff --git a/modules/Makefile.am b/modules/Makefile.am index 5902c4cd9..23089d149 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -434,6 +434,21 @@ app_module_LTLIBRARIES = \ app/app_register.la \ ### +############################################################################### +# +# /_matrix/identity/ +# + +identity_moduledir = @moduledir@ + +identity_identity_v1_la_SOURCES = identity/v1.cc +identity_identity_pubkey_la_SOURCES = identity/pubkey.cc + +identity_module_LTLIBRARIES = \ + identity/identity_v1.la \ + identity/identity_pubkey.la \ + ### + ############################################################################### # # JavaScript diff --git a/modules/identity/pubkey.cc b/modules/identity/pubkey.cc new file mode 100644 index 000000000..c3c4e64b0 --- /dev/null +++ b/modules/identity/pubkey.cc @@ -0,0 +1,77 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +using namespace ircd; + +mapi::header +IRCD_MODULE +{ + "Identity Service 7 :Key management" +}; + +resource +pubkey_resource +{ + "/_matrix/identity/api/v1/pubkey/", + { + "7.1 Get the public key for the passed key ID.", + resource::DIRECTORY + } +}; + +static resource::response +handle_get(client &, + const resource::request &); + +resource::method +method_get +{ + pubkey_resource, "GET", handle_get +}; + +resource::response +handle_get(client &client, + const resource::request &request) +{ + if(request.parv.size() < 1) + throw m::NEED_MORE_PARAMS + { + "keyId path parameter required" + }; + + char buf[256]; + const string_view keyid + { + url::decode(buf, request.parv[0]) + }; + + const string_view algorithm + { + split(keyid, ':').first + }; + + const string_view identifier + { + split(keyid, ':').second + }; + + const string_view public_key + { + + }; + + return resource::response + { + client, http::NOT_FOUND, json::members + { + { "public_key", public_key } + } + }; +} diff --git a/modules/identity/v1.cc b/modules/identity/v1.cc new file mode 100644 index 000000000..863a0f33a --- /dev/null +++ b/modules/identity/v1.cc @@ -0,0 +1,43 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +using namespace ircd; + +mapi::header +IRCD_MODULE +{ + "Identity Service 6 :Status Check" +}; + +resource +identity_resource +{ + "/_matrix/identity/api/v1", + { + "Identity 6.1 :Checks that an identity server is available at this" + " API endpoint." + } +}; + +static resource::response +handle_get(client &client, + const resource::request &request) +{ + return resource::response + { + client, http::NOT_IMPLEMENTED + }; +} + +resource::method +method_get +{ + identity_resource, "GET", handle_get +};