Commit Graph

32 Commits

Author SHA1 Message Date
Marek Pikuła
fe7a3667d4 Complete the major refactor
Major part of #73

Unfortunately, it wasn't possible to split it to multiple smaller
commits, since the changes touched the entire application substantially.
Here is a short list of major changes:

1. Create a separate library (headscale-api), which is used as a
   convenient abstraction layer providing Pythonic interface with
   Pydantic. Headscale API is fully asynchronous library, benefitting
   from improved concurrency for backend requests thus increasing page
   load speed, e.g., on "Machines" page.
2. Create a common common, validated with flask-pydantic API passthrough
   layer from GUI to the backend.
3. Move authentication to a separate (auth.py), consolidating the
   functionality in a single place (with better place for expansion in
   the future).
4. Move configuration management to a separate module (config.py). Use
   Pydantic's BaseSettings for reading values from environment, with
   extensive validation and error reporting.
5. Reduce the number of health checks.
    - Now, most are performed during server initialization. If any test
      fails, the server is started in tainted mode, with only the error
      page exposed (thus reducing the surface of attack in invalid
      state).
    - Key checks are implicit in the requests to the backend and
      guarded by `@headscale.key_check_guard` decorator.
    - Key renewal is moved to server-side scheduler.
6. Introduce type hints to the level satisfactory for mypy static
   analysis. Also, enable some other linters in CI and add optional
   pre-commit hooks.
7. Properly handle some error states. Instead of returning success and
   handling different responses, if something fails, there is HTTP error
   code and standard response for it.
8. General formatting, small rewrites for clarity and more idiomatic
   Python constructs.

Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
2023-04-21 06:02:29 +00:00
Marek Pikuła
358c0086af Apply black and isort auto formatting
Signed-off-by: Marek Pikuła <marek.pikula@embevity.com>
2023-04-21 05:50:28 +00:00
rohow
48db591d25 fix(logger): Field reference error
Fix the error when the server_url in config is not configured.
2023-04-14 17:45:41 +08:00
iFargle
0473290e95 test 2023-03-29 13:59:34 +09:00
iFargle
57a09ca139 test 2023-03-29 13:09:02 +09:00
iFargle
81165a136c test 2023-03-21 14:23:02 +09:00
iFargle
984b415156 Adding a better URL for --login-server 2023-03-21 14:14:33 +09:00
iFargle
12f944426f Add logging 2023-02-28 14:26:46 +09:00
iFargle
37f74ac82d More logging configs 2023-02-28 14:24:46 +09:00
iFargle
0f19484a06 test 2023-02-28 13:53:54 +09:00
iFargle
c94e3f0002 Test 2023-02-28 13:07:07 +09:00
iFargle
90e364d11d Trying create_logger 2023-02-28 08:28:09 +09:00
iFargle
169b552639 In a working state now. 2023-02-27 22:57:38 +09:00
iFargle
0fec4852af test 2023-02-27 22:49:34 +09:00
iFargle
88afde359a test 2023-02-27 22:45:12 +09:00
iFargle
bdbb85bcb9 Test 2023-02-27 22:21:51 +09:00
iFargle
3833a33885 test 2023-02-27 22:03:04 +09:00
iFargle
b3fac98c1c test 2023-02-27 21:54:36 +09:00
iFargle
3db9ed8635 Test 2023-02-27 21:33:06 +09:00
iFargle
be78e2bfdf test 2023-02-27 21:24:37 +09:00
iFargle
9d01a05263 Test 2023-02-27 21:19:12 +09:00
iFargle
aea36e358b Testing more logging 2023-02-27 21:15:58 +09:00
iFargle
3808720800 Testing logging 2023-02-27 20:15:44 +09:00
iFargle
ef8e7f0644 test 2023-02-20 17:23:05 +09:00
iFargle
a0a62c4af6 Updates 2023-02-17 22:41:41 +09:00
iFargle
3f699b9b72 Test 2023-02-17 16:46:49 +09:00
iFargle
2754e568ee Remove unused dependencies and variables 2023-02-16 00:06:31 +09:00
iFargle
d59de909c2 Fixing logging 2023-02-15 19:22:47 +09:00
iFargle
db6449ea10 Update logging 2023-02-15 19:20:44 +09:00
iFargle
58ff00fd38 Update logging 2023-02-15 19:04:47 +09:00
iFargle
5a61b02446 Update logging 2023-02-15 19:02:14 +09:00
iFargle
b5ea066ca6 Initial commit 2023-02-06 04:58:09 +00:00