Mir
application_authorizer.h
Go to the documentation of this file.
1/*
2 * Copyright © Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 or 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIRAL_APPLICATION_AUTHORIZER_H
18#define MIRAL_APPLICATION_AUTHORIZER_H
19
20#include <sys/types.h>
21#include <functional>
22#include <memory>
23
24namespace mir { class Server; }
25namespace mir { namespace frontend { class SessionCredentials; } }
26
27namespace miral
28{
30{
31public:
32 ApplicationCredentials(mir::frontend::SessionCredentials const& creds);
33
34 pid_t pid() const;
35 uid_t uid() const;
36 gid_t gid() const;
37
38private:
39 ApplicationCredentials() = delete;
40
41 mir::frontend::SessionCredentials const& creds;
42};
43
45{
46public:
48 virtual ~ApplicationAuthorizer() = default;
51
52 virtual bool connection_is_allowed(ApplicationCredentials const& creds) = 0;
55 virtual bool screencast_is_allowed(ApplicationCredentials const& creds) = 0;
56 virtual bool prompt_session_is_allowed(ApplicationCredentials const& creds) = 0;
57 virtual bool configure_input_is_allowed(ApplicationCredentials const& creds) = 0;
59};
60
62{
63public:
64 explicit BasicSetApplicationAuthorizer(std::function<std::shared_ptr<ApplicationAuthorizer>()> const& builder);
66
67 void operator()(mir::Server& server);
68 auto the_application_authorizer() const -> std::shared_ptr<ApplicationAuthorizer>;
69
70private:
71 struct Self;
72 std::shared_ptr<Self> self;
73};
74
75template<typename Policy>
77{
78public:
79 template<typename ...Args>
80 explicit SetApplicationAuthorizer(Args const& ...args) :
81 BasicSetApplicationAuthorizer{[&args...]() { return std::make_shared<Policy>(args...); }} {}
82
83 auto the_custom_application_authorizer() const -> std::shared_ptr<Policy>
84 { return std::static_pointer_cast<Policy>(the_application_authorizer()); }
85};
86}
87
88#endif //MIRAL_APPLICATION_AUTHORIZER_H
Definition: application_authorizer.h:45
virtual bool set_base_display_configuration_is_allowed(ApplicationCredentials const &creds)=0
virtual ~ApplicationAuthorizer()=default
virtual bool prompt_session_is_allowed(ApplicationCredentials const &creds)=0
virtual bool configure_display_is_allowed(ApplicationCredentials const &creds)=0
virtual bool set_base_input_configuration_is_allowed(ApplicationCredentials const &creds)=0
virtual bool screencast_is_allowed(ApplicationCredentials const &creds)=0
virtual bool connection_is_allowed(ApplicationCredentials const &creds)=0
ApplicationAuthorizer & operator=(ApplicationAuthorizer const &)=delete
virtual bool configure_input_is_allowed(ApplicationCredentials const &creds)=0
ApplicationAuthorizer(ApplicationAuthorizer const &)=delete
Definition: application_authorizer.h:30
ApplicationCredentials(mir::frontend::SessionCredentials const &creds)
Definition: application_authorizer.h:62
void operator()(mir::Server &server)
auto the_application_authorizer() const -> std::shared_ptr< ApplicationAuthorizer >
BasicSetApplicationAuthorizer(std::function< std::shared_ptr< ApplicationAuthorizer >()> const &builder)
Definition: application_authorizer.h:77
SetApplicationAuthorizer(Args const &...args)
Definition: application_authorizer.h:80
auto the_custom_application_authorizer() const -> std::shared_ptr< Policy >
Definition: application_authorizer.h:83
Definition: application_authorizer.h:25
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.