1 | // SPDX-FileCopyrightText: 2020 Kitsune Ral <kitsune-ral@users.sf.net> |
2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
3 | |
4 | #pragma once |
5 | |
6 | #include "util.h" |
7 | |
8 | #include <QtCore/QUrl> |
9 | #include <QtCore/QObject> |
10 | |
11 | namespace Quotient { |
12 | class Connection; |
13 | |
14 | /*! Single sign-on (SSO) session encapsulation |
15 | * |
16 | * This class is responsible for setting up of a new SSO session, providing |
17 | * a URL to be opened (usually, in a web browser) and handling the callback |
18 | * response after completing the single sign-on, all the way to actually |
19 | * logging the user in. It does NOT open and render the SSO URL, it only does |
20 | * the necessary backstage work. |
21 | * |
22 | * Clients only need to open the URL; the rest is done for them. |
23 | * Client code can look something like: |
24 | * \code |
25 | * QDesktopServices::openUrl( |
26 | * connection->prepareForSso(initialDeviceName)->ssoUrl()); |
27 | * \endcode |
28 | */ |
29 | class QUOTIENT_API SsoSession : public QObject { |
30 | Q_OBJECT |
31 | Q_PROPERTY(QUrl ssoUrl READ ssoUrl CONSTANT) |
32 | Q_PROPERTY(QUrl callbackUrl READ callbackUrl CONSTANT) |
33 | public: |
34 | SsoSession(Connection* connection, const QString& initialDeviceName, |
35 | const QString& deviceId = {}); |
36 | ~SsoSession() override = default; |
37 | |
38 | QUrl ssoUrl() const; |
39 | QUrl callbackUrl() const; |
40 | |
41 | private: |
42 | class Private; |
43 | ImplPtr<Private> d; |
44 | }; |
45 | } // namespace Quotient |
46 | |