WIP: documenting
[src/app-framework-main.git] / docs / a-history.md
1 HISTORY OF THE AGL FRAMEWORK
2 ============================
3
4 ## Brief history
5
6 - March 2016: proposal of IoT.BzH based on refit of tizen framework
7 - December 2016: adoption for AGL
8 - March 2017: switch to systemd launcher
9 - November 2017: switch to systemd "system"
10 - May 2018: switch to meta-security
11 - June 2019: switch to multi-user (to agl-driver only)
12 - October 2019: switch to cynagora
13 - January 2020: Integrates Token logic compatible with OAuth2
14
15 ## Origin of the AGL Application Framework
16
17 The Application Framework of AGL implements the security model
18 of Tizen 3 but differs from the Application Framework of Tizen
19 3.
20
21 During the first works in having the security model of Tizen
22 integrated in AGL (Automotive Grade Linux) distribution, it became
23 quickly obvious that the count of components specific to Tizen
24 to integrate was huge.
25
26 Here is a minimal list of what was needed:
27
28 - platform/appfw/app-installers
29 - platform/core/security/cert-svc
30 - platform/core/appfw/ail
31 - platform/core/appfw/aul-1
32 - platform/core/appfw/libslp-db-util
33 - platform/core/appfw/pkgmgr-info
34 - platform/core/appfw/slp-pkgmgr
35
36 But this list isn't complete because many dependencies are hidden.
37 Those hidden dependencies are including some common libraries but also many
38 tizen specific sub-components:
39
40 - iniparser
41 - bundle
42 - dlog,
43 - libtzplatform-config
44 - db-util
45 - vconf-buxton
46 - ...
47
48 This is an issue because AGL is not expected to be Tizen.
49 Taking it would either need to patch it for removing unwanted components
50 or to take all of them.
51
52 However, a careful study of the core components of the security framework
53 of Tizen showed that their dependencies to Tizen are light (and since some
54 of our work, there is no more dependency to tizen).
55
56 These components are :
57
58 - **cynara**
59 - **security-manager**
60 - **D-Bus aware of cynara**
61
62 Luckily, at the time of that work, 2016, these core security components of
63 Tizen were provided by [meta-intel-iot-security][meta-intel], a set of yocto
64 layers.
65
66 These layers were created by Intel to isolate Tizen specific security
67 components from the initial port of Tizen to Yocto.
68 The 3 layers are providing components for:
69
70 - Implementing Smack LSM
71 - Implementing Integrity Measurement Architecture
72 - Implementing Tizen Security Framework
73
74 We took the decision to use these security layers that provide the
75 basis of the Tizen security, the security framework.
76
77 For the components of the application framework, built top of
78 the security framework, instead of pulling the huge set of packages
79 from Tizen, we decided to refit it by developing a tiny set of
80 components that would implement the same behaviour but without all
81 the dependencies and with minor architectural improvements for AGL.
82
83 These components were :
84
85 - **afm-system-daemon**
86 - **afm-user-daemon**
87
88 They provides infrastructure for installing, uninstalling,
89 launching, terminating, pausing and resuming applications in
90 a multi user secure environment.
91
92 A third component exists in the framework, the binder **afb-daemon**.
93 The binder provides the easiest way to provide secured API for
94 any tier.
95
96 <!-- pagebreak -->
97
98 ## Evolution of the application framework within AGL
99
100 After its first version in March 2016 and its adoption by AGL
101 in december 2016, the framework evolved slowly.
102
103 In March 2017, the application launcher of the framework was
104 fully replaced by systemd as a launcher. Many good reasons
105 advocated this replacement:
106
107 - one less component to maintain
108 - immediate availability of many advanced features (cgroups, security,
109   automatic start, ...)
110 - systemd is now a well known and used standard
111 - the process of generating systemd services is tunable by implementors
112
113 In November 2017, after feedback from experiments with systemd and for
114 solving issues related to security of AGL, the user applications and services
115 are switched from the systemd user space to the system space using
116 parametric UID.
117
118 After Intel abandonned their [meta-intel-iot-security][meta-intel],
119 AGL switched to [meta-security][meta-security].
120
121 In June 2019, the started user is no more root and most of services
122 are running as not root and with lowered capabilities.
123
124 ## Links between the "Security framework" and the "Application framework"
125
126 The security framework refers to the security model used to ensure
127 security and to the tools that are provided for implementing that model.
128
129 The security model refers to how DAC (Discretionary Access Control),
130 MAC (Mandatory Access Control) and Capabilities are used by the system
131 to ensure security and privacy.
132 It also includes features of reporting using audit features and by managing
133 logs and alerts.
134
135 The application framework manages the applications:
136
137 - installing
138 - uninstalling
139 - starting
140 - pausing
141 - listing
142 - ...
143
144 The application framework uses the security model/framework
145 to ensure the security and the privacy of the applications that
146 it manages.
147
148 The application framework must be compliant with the underlying
149 security model/framework.
150 But it should hide it to the applications.
151
152 ## The security framework
153
154 The implemented security model is the security model of Tizen 3.
155 This model is described [here][tizen-secu-3].
156
157 The security framework then comes from Tizen 3 but through
158 the [meta-intel].
159 It includes:
160
161 - **Security-Manager**
162 - **Cynara**
163 - **D-Bus** compliant to Cynara.
164
165 Two patches are applied to the security-manager.
166 The goal of these patches is to remove specific dependencies with Tizen packages that are not needed by AGL.
167 None of these patches adds or removes any behaviour.
168
169 **In theory, the security framework/model is an implementation details
170 that should not impact the layers above the application framework**.
171
172 The security framework of Tizen provides "nice lad" a valuable component to
173 scan log files and analyse auditing.
174 This component is still in development.
175
176 ## The application framework
177
178 The application framework on top of the security framework
179 provides the components to install and uninstall applications
180 and to run it in a secured environment.
181
182 The goal is to manage applications and to hide the details of
183 the security framework to the applications.
184
185 For the reasons explained in introduction, we did not used the
186 application framework of Tizen as is but used an adaptation of it.
187
188 The basis is kept identical:
189
190 - The applications are distributed in a digitally signed container that must
191   match the specifications of widgets (web applications).
192
193 This is described by the technical recommendations [widgets] and
194 [widgets-digsig] of the W3 consortium.
195
196 This model allows:
197
198 - The distribution of HTML, QML and binary applications.
199 - The management of signatures of the widget packages.
200
201 This basis is not meant as being rigid and it can be extended in the
202 future to include for example incremental delivery.
203
204 [meta-intel]:       https://github.com/01org/meta-intel-iot-security                "A collection of layers providing security technologies"
205 [meta-security]:    https://git.yoctoproject.org/cgit/cgit.cgi/meta-security/       "security and hardening tools and libraries for Linux"
206 [widgets]:          http://www.w3.org/TR/widgets                                    "Packaged Web Apps"
207 [widgets-digsig]:   http://www.w3.org/TR/widgets-digsig                             "XML Digital Signatures for Widgets"
208 [libxml2]:          http://xmlsoft.org/html/index.html                              "libxml2"
209 [openssl]:          https://www.openssl.org                                         "OpenSSL"
210 [xmlsec]:           https://www.aleksey.com/xmlsec                                  "XMLSec"
211 [json-c]:           https://github.com/json-c/json-c                                "JSON-c"
212 [d-bus]:            http://www.freedesktop.org/wiki/Software/dbus                   "D-Bus"
213 [libzip]:           http://www.nih.at/libzip                                        "libzip"
214 [cmake]:            https://cmake.org                                               "CMake"
215 [security-manager]: https://wiki.tizen.org/wiki/Security/Tizen_3.X_Security_Manager "Security-Manager"
216 [app-manifest]:     http://www.w3.org/TR/appmanifest                                "Web App Manifest"
217 [tizen-security]:   https://wiki.tizen.org/wiki/Security                            "Tizen security home page"
218 [tizen-secu-3]:     https://wiki.tizen.org/wiki/Security/Tizen_3.X_Overview         "Tizen 3 security overview"
219 [AppFW-APP_install_sequences]: pictures/AppFW-APP_install_sequences.svg
220 [Security_model_history]: pictures/Security_model_history.svg