• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 1047260214

24 Oct 2023 08:50AM UTC coverage: 80.226% (-0.1%) from 80.34%
1047260214

push

gitlab-ci

oleorhagen
test(artifact): Add signature verification of the test artifact for RSA

Signed-off-by: Ole Petter <ole.orhagen@northern.tech>

6873 of 8567 relevant lines covered (80.23%)

9388.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/mender-auth/ipc/server.hpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15

16
#ifndef MENDER_AUTH_IPC_SERVER_HPP
17
#define MENDER_AUTH_IPC_SERVER_HPP
18

19
#include <functional>
20
#include <string>
21

22
#include <common/conf.hpp>
23
#include <common/dbus.hpp>
24
#include <common/error.hpp>
25
#include <common/events.hpp>
26
#include <common/http.hpp>
27
#include <common/path.hpp>
28

29
#include <api/api.hpp>
30
#include <api/auth.hpp>
31

32
namespace mender {
33
namespace auth {
34
namespace ipc {
35

36

37
using namespace std;
38

39
namespace auth_client = mender::api::auth;
40
namespace conf = mender::common::conf;
41
namespace dbus = mender::common::dbus;
42
namespace error = mender::common::error;
43
namespace events = mender::common::events;
44
namespace log = mender::common::log;
45
namespace path = mender::common::path;
46

47
class Caching {
48
public:
49
        Caching(events::EventLoop &loop, const conf::MenderConfig &config) :
×
50
                servers_ {config.servers},
×
51
                tenant_token_ {config.tenant_token},
×
52
                client_ {config.GetHttpClientConfig(), loop},
53
                default_identity_script_path_ {config.paths.GetIdentityScript()},
54
                dbus_server_ {loop, "io.mender.AuthenticationManager"} {};
×
55

56
        error::Error Listen(
57
                const string &private_key_path = "", const string &identity_script_path = "");
58

59
        string GetServerURL() {
60
                return this->cached_server_url_;
61
        }
62

63
        string GetJWTToken() {
64
                return this->cached_jwt_token_;
65
        }
66

67
        void Cache(const string &token, const string &url) {
68
                this->cached_jwt_token_ = token;
69
                this->cached_server_url_ = url;
70
        }
71

72
private:
73
        void ClearCache() {
74
                Cache("", "");
75
        }
76

77
        void CacheAPIResponse(const auth_client::APIResponse &resp) {
78
                if (resp) {
79
                        Cache(resp.value().token, resp.value().server_url);
80
                        return;
81
                }
82
                ClearCache();
83
        };
84

85
        string cached_jwt_token_;
86
        string cached_server_url_;
87
        bool auth_in_progress_ = false;
88

89
        const vector<string> &servers_;
90
        const string tenant_token_;
91
        http::Client client_;
92
        string default_identity_script_path_;
93
        dbus::DBusServer dbus_server_;
94
};
95

96
using Server = Caching;
97

98
} // namespace ipc
99
} // namespace auth
100
} // namespace mender
101

102

103
#endif // MENDER_AUTH_IPC_SERVER_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc