aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-09 19:37:12 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-09 21:16:08 +0900
commitee1d26586572d4d74105a0713d0237dbc2d183f0 (patch)
tree22d81199ca8b77023710a2509a9fbb43d137143a /lib/csapi
parent0ec97b031c4d89acc9ea6e343620f3762f8eb51b (diff)
downloadlibquotient-ee1d26586572d4d74105a0713d0237dbc2d183f0.tar.gz
libquotient-ee1d26586572d4d74105a0713d0237dbc2d183f0.zip
csapi: add RedirectToSSOJob
This is actually a rehash (MSC1721) of redirectToCAS that existed before but was explicitly disabled in the library because of its seeming uselessness in the context of non-web clients. On the second thought, however, `RedirectToSSOJob::makeRequestURL()` can actually be used to open a web browser from a non-web client in order to perform the login procedure.
Diffstat (limited to 'lib/csapi')
-rw-r--r--lib/csapi/sso_login_redirect.cpp38
-rw-r--r--lib/csapi/sso_login_redirect.h39
2 files changed, 77 insertions, 0 deletions
diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp
new file mode 100644
index 00000000..7323951c
--- /dev/null
+++ b/lib/csapi/sso_login_redirect.cpp
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "sso_login_redirect.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+BaseJob::Query queryToRedirectToSSO(const QString& redirectUrl)
+{
+ BaseJob::Query _q;
+ addParam<>(_q, QStringLiteral("redirectUrl"), redirectUrl);
+ return _q;
+}
+
+QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/login/sso/redirect",
+ queryToRedirectToSSO(redirectUrl));
+}
+
+static const auto RedirectToSSOJobName = QStringLiteral("RedirectToSSOJob");
+
+RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl)
+ : BaseJob(HttpVerb::Get, RedirectToSSOJobName,
+ basePath % "/login/sso/redirect",
+ queryToRedirectToSSO(redirectUrl),
+ {}, false)
+{
+}
+
diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h
new file mode 100644
index 00000000..c09365b0
--- /dev/null
+++ b/lib/csapi/sso_login_redirect.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ /// Redirect the user's browser to the SSO interface.
+ ///
+ /// A web-based Matrix client should instruct the user's browser to
+ /// navigate to this endpoint in order to log in via SSO.
+ ///
+ /// The server MUST respond with an HTTP redirect to the SSO interface.
+ class RedirectToSSOJob : public BaseJob
+ {
+ public:
+ /*! Redirect the user's browser to the SSO interface.
+ * \param redirectUrl
+ * URI to which the user will be redirected after the homeserver has
+ * authenticated the user with SSO.
+ */
+ explicit RedirectToSSOJob(const QString& redirectUrl);
+
+ /*! Construct a URL without creating a full-fledged job object
+ *
+ * This function can be used when a URL for
+ * RedirectToSSOJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl);
+
+ };
+} // namespace QMatrixClient