Skip to content

Commit 3eced29

Browse files
authored
AppEcosystem -> AppAPI refactor(1) (#116)
It was decided to change the name of App Ecosystem to AppAPI before its first release at the end of September. It was also decided to make authentication as simple as possible, and for remotely running applications, transport layer encryption should always be used. This is draft, waiting for AppAPI to be updated with rewritten new auth to make benches. --------- Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 483589b commit 3eced29

31 files changed

+208
-281
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ jobs:
117117
working-directory: nc_py_api
118118
run: python3 -m pip -v install ".[dev]"
119119

120-
- name: Checkout AppEcosystemV2
120+
- name: Checkout AppAPI
121121
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
122122
with:
123-
path: apps/app_ecosystem_v2
124-
repository: cloud-py-api/app_ecosystem_v2
123+
path: apps/app_api
124+
repository: cloud-py-api/app_api
125125

126-
- name: Install AppEcosystemV2
126+
- name: Install AppAPI
127127
run: |
128-
patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
129-
php occ app:enable app_ecosystem_v2
128+
patch -p 1 -i apps/app_api/base_php.patch
129+
php occ app:enable app_api
130130
cd nc_py_api
131131
coverage run --data-file=.coverage.ci_install tests/_install.py &
132132
echo $! > /tmp/_install.pid
@@ -272,18 +272,18 @@ jobs:
272272
working-directory: nc_py_api
273273
run: python3 -m pip -v install ".[dev]"
274274

275-
- name: Checkout AppEcosystemV2
275+
- name: Checkout AppAPI
276276
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
277277
if: ${{ !startsWith(matrix.nextcloud, '26.') }}
278278
with:
279-
path: apps/app_ecosystem_v2
280-
repository: cloud-py-api/app_ecosystem_v2
279+
path: apps/app_api
280+
repository: cloud-py-api/app_api
281281

282-
- name: Install AppEcosystemV2
282+
- name: Install AppAPI
283283
if: ${{ !startsWith(matrix.nextcloud, '26.') }}
284284
run: |
285-
patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
286-
php occ app:enable app_ecosystem_v2
285+
patch -p 1 -i apps/app_api/base_php.patch
286+
php occ app:enable app_api
287287
cd nc_py_api
288288
coverage run --data-file=.coverage.ci_install tests/_install.py &
289289
echo $! > /tmp/_install.pid
@@ -416,16 +416,16 @@ jobs:
416416
working-directory: nc_py_api
417417
run: python3 -m pip -v install ".[dev]"
418418

419-
- name: Checkout AppEcosystemV2
419+
- name: Checkout AppAPI
420420
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
421421
with:
422-
path: apps/app_ecosystem_v2
423-
repository: cloud-py-api/app_ecosystem_v2
422+
path: apps/app_api
423+
repository: cloud-py-api/app_api
424424

425-
- name: Install AppEcosystemV2
425+
- name: Install AppAPI
426426
run: |
427-
patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
428-
php occ app:enable app_ecosystem_v2
427+
patch -p 1 -i apps/app_api/base_php.patch
428+
php occ app:enable app_api
429429
cd nc_py_api
430430
coverage run --data-file=.coverage.ci_install tests/_install.py &
431431
echo $! > /tmp/_install.pid
@@ -536,15 +536,15 @@ jobs:
536536
working-directory: nc_py_api
537537
run: python3 -m pip -v install ".[dev]"
538538

539-
- name: Checkout AppEcosystemV2
539+
- name: Checkout AppAPI
540540
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
541541
with:
542-
path: apps/app_ecosystem_v2
543-
repository: cloud-py-api/app_ecosystem_v2
542+
path: apps/app_api
543+
repository: cloud-py-api/app_api
544544

545-
- name: Install AppEcosystemV2
545+
- name: Install AppAPI
546546
run: |
547-
php occ app:enable app_ecosystem_v2
547+
php occ app:enable app_api
548548
cd nc_py_api
549549
coverage run --data-file=.coverage.ci_install tests/_install.py &
550550
echo $! > /tmp/_install.pid
@@ -705,7 +705,7 @@ jobs:
705705
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
706706
coverage combine && coverage xml && coverage html
707707
env:
708-
SKIP_AE_TESTS: 1
708+
SKIP_AA_TESTS: 1
709709
NPA_NC_CERT: ''
710710

711711
- name: HTML coverage to artifacts
@@ -799,19 +799,19 @@ jobs:
799799
working-directory: nc_py_api
800800
run: python3 -m pip -v install ".[dev]"
801801

802-
- name: Checkout AppEcosystemV2
802+
- name: Checkout AppAPI
803803
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
804804
with:
805-
path: apps/app_ecosystem_v2
806-
repository: cloud-py-api/app_ecosystem_v2
805+
path: apps/app_api
806+
repository: cloud-py-api/app_api
807807

808808
- name: Patch base.php
809809
if: ${{ startsWith(matrix.nextcloud, 'stable26') }}
810-
run: patch -p 1 -i apps/app_ecosystem_v2/base_php.patch
810+
run: patch -p 1 -i apps/app_api/base_php.patch
811811

812-
- name: Install AppEcosystemV2
812+
- name: Install AppAPI
813813
run: |
814-
php occ app:enable app_ecosystem_v2
814+
php occ app:enable app_api
815815
cd nc_py_api
816816
coverage run --data-file=.coverage.ci_install tests/_install.py &
817817
echo $! > /tmp/_install.pid

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.2.0 - 2023-09-11]
6+
7+
### Changed
8+
9+
- AppEcosystem_V2 Project was renamed to App_API, adjust all routes, examples, and docs for this.
10+
- The Application Authentication mechanism was changed to a much simple one.
11+
512
## [0.1.0 - 2023-09-06]
613

714
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The **Nextcloud** class functions as a standard Nextcloud client,
4545
enabling you to make API requests using a username and password.
4646

4747
On the other hand, the **NextcloudApp** class is designed for creating applications for Nextcloud.<br>
48-
It uses the [AppEcosystem](https://github.com/cloud-py-api/app_ecosystem_v2) to allow
48+
It uses the [AppAPI](https://github.com/cloud-py-api/app_api) to allow
4949
applications to impersonate users through a separate authentication mechanism.
5050

5151
Both classes offer most of the same APIs,

docs/DevSetup.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Suggested IDE: **PyCharm**, but of course you can use any IDE you like for this
1010
Steps to setup up the development environment:
1111

1212
#. Setup Nextcloud locally or remotely.
13-
#. Install `AppEcosystem <https://github.com/cloud-py-api/app_ecosystem_v2>`_, follow it's steps to register ``deploy daemon`` if needed.
13+
#. Install `AppAPI <https://github.com/cloud-py-api/app_api>`_, follow it's steps to register ``deploy daemon`` if needed.
1414
#. Clone the `nc_py_api <https://github.com/cloud-py-api/nc_py_api>`_ with :command:`shell`::
1515

1616
git clone https://github.com/cloud-py-api/nc_py_api.git
@@ -39,7 +39,7 @@ Steps to setup up the development environment:
3939

4040
pre-commit install
4141

42-
#. If ``deploy daemon`` is registered for AppEcosystem, register **nc_py_api** as an application with :command:`shell`::
42+
#. If ``deploy daemon`` is registered for AppAPI, register **nc_py_api** as an application with :command:`shell`::
4343

4444
make register28
4545

docs/NextcloudApp.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Writing a Nextcloud Application
22
===============================
33

4-
This chapter assumes that you are already familiar with the `concepts <https://cloud-py-api.github.io/app_ecosystem_v2/Concepts.html>`_ of the AppEcosystem.
4+
This chapter assumes that you are already familiar with the `concepts <https://cloud-py-api.github.io/app_api/Concepts.html>`_ of the AppAPI.
55

66
As a first step, let's take a look at the structure of a basic Python application.
77

@@ -47,7 +47,7 @@ First register ``manual_install`` daemon:
4747

4848
.. code-block:: shell
4949
50-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
50+
php occ app_api:daemon:register manual_install "Manual Install" manual-install 0 0 0
5151
5252
Then, launch your application. Since this is a manual deployment, it's your responsibility to set minimum of the environment variables.
5353
Here they are:
@@ -56,7 +56,7 @@ Here they are:
5656
* APP_PORT - Port on which application listen for the requests from the Nextcloud.
5757
* APP_SECRET - Secret for ``hmac`` signature generation.
5858
* APP_VERSION - Version of the application.
59-
* AE_VERSION - Version of the AppEcosystem.
59+
* AE_VERSION - Version of the AppAPI.
6060
* NEXTCLOUD_URL - URL at which the application can access the Nextcloud API.
6161

6262
You can find values for these environment variables in the **Skeleton** or **ToGif** run configurations.
@@ -65,7 +65,7 @@ After launching your application, execute the following command in the Nextcloud
6565

6666
.. code-block:: shell
6767
68-
php occ app_ecosystem_v2:app:register YOUR_APP_ID manual_install --json-info \
68+
php occ app_api:app:register YOUR_APP_ID manual_install --json-info \
6969
"{\"appid\":\"YOUR_APP_ID\",\"name\":\"YOUR_APP_DISPLAY_NAME\",\"daemon_config_name\":\"manual_install\",\"version\":\"YOU_APP_VERSION\",\"secret\":\"YOUR_APP_SECRET\",\"host\":\"host.docker.internal\",\"scopes\":{\"required\":[2, 10, 11],\"optional\":[30, 31, 32, 33]},\"port\":SELECTED_PORT,\"protocol\":\"http\",\"system_app\":0}" \
7070
-e --force-scopes
7171
@@ -79,7 +79,7 @@ Examples for such Makefiles can be found in this repository:
7979
`ToGif <https://github.com/cloud-py-api/nc_py_api/blob/main/examples/as_app/to_gif/Makefile>`_ ,
8080
`nc_py_api <https://github.com/cloud-py-api/nc_py_api/blob/main/scripts/dev_register.sh>`_
8181

82-
During the execution of `php occ app_ecosystem_v2:app:register`, the **enabled_handler** will be called,
82+
During the execution of `php occ app_api:app:register`, the **enabled_handler** will be called,
8383
as we pass the flag ``-e``, meaning ``enable after registration``.
8484

8585
This is likely all you need to start debugging and developing an application for Nextcloud.
@@ -89,7 +89,7 @@ Pack & Deploy
8989

9090
Before reading this chapter, please review the basic information about deployment
9191
and the currently supported types of
92-
`deployments configurations <https://cloud-py-api.github.io/app_ecosystem_v2/DeployConfigurations.html>`_ in the AppEcosystem documentation.
92+
`deployments configurations <https://cloud-py-api.github.io/app_api/DeployConfigurations.html>`_ in the AppAPI documentation.
9393

9494
Docker Deploy Daemon
9595
""""""""""""""""""""
@@ -140,7 +140,7 @@ First of all, we modernize info.ixml, add the API groups we need for this to wor
140140
</optional>
141141
</scopes>
142142
143-
.. note:: Full list of avalaible API scopes can be found `here <https://cloud-py-api.github.io/app_ecosystem_v2/tech_details/ApiScopes.html>`_.
143+
.. note:: Full list of avalaible API scopes can be found `here <https://cloud-py-api.github.io/app_api/tech_details/ApiScopes.html>`_.
144144

145145
After that we extend the **enabled** handler and include there registration of the drop-down list element:
146146

@@ -194,7 +194,7 @@ heavy calculations and we cannot guarantee a fast completion time, it is recomme
194194
an empty response (which will be a status of 200) and in the background already slowly perform operations.
195195

196196
The last parameter is a structure describing the action and the file on which it needs to be performed,
197-
which is passed by the Appecosystem when clicking on the drop-down context menu of the file.
197+
which is passed by the AppAPI when clicking on the drop-down context menu of the file.
198198

199199
We use the built method :py:meth:`~nc_py_api.ex_app.ui.files.UiActionFileInfo.to_fs_node` into the structure to convert it
200200
into a standard :py:class:`~nc_py_api.files.FsNode` class that describes the file and pass the FsNode class instance to the background task.

docs/NextcloudTalkBot.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Nextcloud Talk Bot API in Applications
22
======================================
33

4-
The AppEcosystem is an excellent choice for developing and deploying bots for Nextcloud Talk.
4+
The AppAPI is an excellent choice for developing and deploying bots for Nextcloud Talk.
55

66
Bots for Nextcloud Talk, in essence, don't differ significantly from regular external applications.
77
The functionality of an external application can include just the bot or provide additional functionalities as well.

docs/benchmarks/AppEcosystem.rst renamed to docs/benchmarks/AppAPI.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
AppEcosystem Benchmarks
2-
=======================
1+
AppAPI Benchmarks
2+
=================
33

4-
In the current implementation, applications written and using the AppEcosystem
4+
In the current implementation, applications written and using the AppAPI
55
so far in most cases will be authenticated at the beginning of each action.
66

77
*A future enhancement that can be implemented is the addition of a session cache.
88
This feature would eliminate the need for re-authorization for subsequent actions performed
99
by the same user within a certain time frame.
1010
The implementation of this session cache would be seamless for developers and require no additional actions.*
1111

12-
It is important to note that the AppEcosystem authentication type is currently the fastest among available options.
12+
It is important to note that the AppAPI authentication type is currently the fastest among available options.
1313
Compared to traditional username/password authentication and app password authentication,
14-
both of which are considerably slower, the AppEcosystem provides a significant advantage in terms of speed.
14+
both of which are considerably slower, the AppAPI provides a significant advantage in terms of speed.
1515

1616
When considering data transfer speed, it is worth mentioning
17-
that the AppEcosystem's upload speed may be slightly lower, around 6-8 percent, for large data transfers.
17+
that the AppAPI's upload speed may be slightly lower, around 6-8 percent, for large data transfers.
1818
This decrease in speed is due to the authentication process, which involves hashing all data.
1919
However, for loading any data, there is no slowdown compared to standard methods.
2020

@@ -26,14 +26,14 @@ this aspect is beyond the scope of the discussed issue.
2626
Conclusion
2727
----------
2828

29-
In summary, the AppEcosystem authentication offers fast and secure access to user data.
29+
In summary, the AppAPI authentication offers fast and secure access to user data.
3030
With the potential addition of a session cache in the future, the authentication process can become even more efficient
3131
and seamless for users. The slight decrease in upload speed for large data transfers
3232
is a trade-off for the enhanced security provided by the authentication process.
3333

34-
Overall, the AppEcosystem authentication proves to be a reliable and effective method for application authentication.
34+
Overall, the AppAPI authentication proves to be a reliable and effective method for application authentication.
3535

36-
.. _appecosystem-bench-results:
36+
.. _appapi-bench-results:
3737

3838
Detailed Benchmark Results
3939
--------------------------

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Have a great time with Python and Nextcloud!
3636
Options
3737
reference/index.rst
3838
DevSetup
39-
benchmarks/AppEcosystem.rst
39+
benchmarks/AppAPI.rst
4040

4141
Indices and tables
4242
==================

examples/as_app/skeleton/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ build-push:
2626

2727
.PHONY: deploy
2828
deploy:
29-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:deploy skeleton docker_dev \
29+
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy skeleton docker_dev \
3030
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
3131

3232
.PHONY: run28
3333
run28:
34-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent || true
35-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes \
34+
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister skeleton --silent || true
35+
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register skeleton docker_dev -e --force-scopes \
3636
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
3737

3838
.PHONY: run27
3939
run27:
40-
docker exec master-stable27-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent || true
41-
docker exec master-stable27-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton docker_dev -e --force-scopes \
40+
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister skeleton --silent || true
41+
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register skeleton docker_dev -e --force-scopes \
4242
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml
4343

4444
.PHONY: manual_register
4545
manual_register:
46-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:unregister skeleton --silent || true
47-
docker exec master-nextcloud-1 sudo -u www-data php occ app_ecosystem_v2:app:register skeleton manual_install --json-info \
46+
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister skeleton --silent || true
47+
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register skeleton manual_install --json-info \
4848
"{\"appid\":\"skeleton\",\"name\":\"App Skeleton\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"host\":\"host.docker.internal\",\"port\":9030,\"scopes\":{\"required\":[],\"optional\":[]},\"protocol\":\"http\",\"system_app\":0}" \
4949
-e --force-scopes

examples/as_app/talk_bot/HOW_TO_INSTALL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
How To Install
22
==============
33

4-
Currently, while AppEcosystem hasn't been published on the App Store, and App Store support hasn't been added yet,
4+
Currently, while AppAPI hasn't been published on the App Store, and App Store support hasn't been added yet,
55
installation is a little bit tricky.
66

77
Steps to Install:
88

9-
1. [Install AppEcosystem](https://cloud-py-api.github.io/app_ecosystem_v2/Installation.html)
10-
2. Create a deployment daemon according to the [instructions](https://cloud-py-api.github.io/app_ecosystem_v2/CreationOfDeployDaemon.html#create-deploy-daemon) of the Appecosystem
11-
3. php occ app_ecosystem_v2:app:deploy talk_bot "daemon_deploy_name" \
9+
1. [Install AppEcosystem](https://cloud-py-api.github.io/app_api/Installation.html)
10+
2. Create a deployment daemon according to the [instructions](https://cloud-py-api.github.io/app_api/CreationOfDeployDaemon.html#create-deploy-daemon) of the AppPI
11+
3. php occ app_api:app:deploy talk_bot "daemon_deploy_name" \
1212
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/talk_bot/appinfo/info.xml
1313

1414
to deploy a docker image with Bot to docker.
1515

16-
4. php occ app_ecosystem_v2:app:register talk_bot "daemon_deploy_name" -e --force-scopes \
16+
4. php occ app_api:app:register talk_bot "daemon_deploy_name" -e --force-scopes \
1717
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/talk_bot/appinfo/info.xml
1818

1919
to call its **enable** handler and accept all required API scopes by default.

0 commit comments

Comments
 (0)