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

mendersoftware / mender / 1057637229

01 Nov 2023 01:17PM UTC coverage: 79.933% (-0.3%) from 80.207%
1057637229

push

gitlab-ci

oleorhagen
chore: Alias mender-authd.service -> mender-client.service

This aliases the systemd.service for `mender-authd` to `mender-client`, so that
other existing third-party services relying on it will still work transparently.

Ticket: MEN-6812

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

6899 of 8631 relevant lines covered (79.93%)

9322.97 hits per line

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

0.0
/src/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
#include <mender-auth/http_forwarder.hpp>
33

34
namespace mender {
35
namespace auth {
36
namespace ipc {
37

38

39
using namespace std;
40

41
namespace conf = mender::common::conf;
42
namespace crypto = mender::common::crypto;
43
namespace dbus = mender::common::dbus;
44
namespace error = mender::common::error;
45
namespace events = mender::common::events;
46
namespace log = mender::common::log;
47
namespace path = mender::common::path;
48

49
namespace auth_client = mender::api::auth;
50

51
namespace http_forwarder = mender::auth::http_forwarder;
52

53
class AuthenticatingForwarder {
54
public:
55
        AuthenticatingForwarder(events::EventLoop &loop, const conf::MenderConfig &config) :
×
56
                servers_ {config.servers},
×
57
                tenant_token_ {config.tenant_token},
×
58
                client_ {config.GetHttpClientConfig(), loop},
59
                forwarder_ {http::ServerConfig {}, config.GetHttpClientConfig(), loop},
×
60
                default_identity_script_path_ {config.paths.GetIdentityScript()},
61
                dbus_server_ {loop, "io.mender.AuthenticationManager"} {};
×
62

63
        error::Error Listen(const crypto::Args &args, const string &identity_script_path = "");
64

65
        string GetServerURL() {
66
                return this->cached_server_url_;
67
        }
68

69
        string GetJWTToken() {
70
                return this->cached_jwt_token_;
71
        }
72

73
        void Cache(const string &token, const string &url) {
74
                this->cached_jwt_token_ = token;
75
                this->cached_server_url_ = url;
76
        }
77

78
        const http_forwarder::Server &GetForwarder() const {
79
                return forwarder_;
80
        }
81

82
private:
83
        void ClearCache() {
84
                Cache("", "");
85
        }
86

87
        void FetchJwtTokenHandler(auth_client::APIResponse &resp);
88

89
        string cached_jwt_token_;
90
        string cached_server_url_;
91
        bool auth_in_progress_ = false;
92

93
        const vector<string> &servers_;
94
        const string tenant_token_;
95
        http::Client client_;
96
        http_forwarder::Server forwarder_;
97
        string default_identity_script_path_;
98
        dbus::DBusServer dbus_server_;
99
};
100

101
using Server = AuthenticatingForwarder;
102

103
} // namespace ipc
104
} // namespace auth
105
} // namespace mender
106

107

108
#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