Commit Graph

327 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
itbencn
2fdbbf5519 fix add_machine bug & foramt 2023-04-21 01:28:56 +08:00
Marek Pikuła
df6f337a25 Remove introspection_endpoint from required secrets
The field is not mandatory and some OIDC providers (such as Nextcloud)
don't provide it resulting in a key error.

Also, refactored client secrets to use json.dumps() for better code
readibility.

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
2023-04-02 20:17:52 +02:00
iFargle
a6b98f76b3 tset 2023-03-29 19:23:58 +09:00
iFargle
79bcf516e7 test 2023-03-29 18:26:31 +09:00
iFargle
0473290e95 test 2023-03-29 13:59:34 +09:00
iFargle
c0e1117355 Testing a routes page 2023-03-23 19:10:22 +09:00
iFargle
880309fa6d test 2023-03-21 21:08:02 +09:00
iFargle
e02385f35b test 2023-03-21 21:05:16 +09:00
iFargle
89f6896b34 test 2023-03-21 14:41:44 +09:00
iFargle
4eca688e55 Forgot to add the block for inpage_search 2023-03-21 14:38:09 +09:00
iFargle
984b415156 Adding a better URL for --login-server 2023-03-21 14:14:33 +09:00
iFargle
6899f55543 add search UI element structure 2023-03-21 13:57:17 +09:00
iFargle
3246db9e56 test 2023-03-17 20:48:29 +09:00
iFargle
1031fb0a64 test 2023-03-17 18:35:52 +09:00
iFargle
7474a608a5 test 2023-03-17 17:57:34 +09:00
iFargle
8670305ace test 2023-03-17 17:48:04 +09:00
iFargle
d5df73c9d0 test 2023-03-17 17:31:22 +09:00
iFargle
03b3d0789a test 2023-03-17 17:25:51 +09:00
iFargle
290ff83b28 test 2023-03-17 17:21:25 +09:00
iFargle
d1728ccc56 test 2023-03-17 17:12:30 +09:00
iFargle
0a06ab8dfd test 2023-03-17 17:07:14 +09:00
iFargle
0eb98f3ae0 test 2023-03-17 17:02:31 +09:00
iFargle
e46132576a test 2023-03-17 15:29:48 +09:00
iFargle
37438a4757 test 2023-03-17 15:26:07 +09:00
iFargle
eb17859357 test 2023-03-17 15:23:02 +09:00
iFargle
e7ba9d92f0 test 2023-03-17 15:19:15 +09:00
iFargle
8a17d86853 test 2023-03-17 15:15:48 +09:00
iFargle
3f3aacbee1 test 2023-03-17 15:05:26 +09:00
iFargle
77f7b8138e test 2023-03-17 14:40:39 +09:00
iFargle
6a7e9ee3ce test 2023-03-17 14:36:19 +09:00
iFargle
e7b41b532b test 2023-03-17 14:29:54 +09:00
iFargle
a8597b98a4 test 2023-03-17 14:23:42 +09:00
iFargle
7883a2dd65 test 2023-03-17 14:20:32 +09:00
iFargle
bc7077221b test 2023-03-17 14:15:19 +09:00
iFargle
52477a2226 test 2023-03-17 14:09:55 +09:00
iFargle
653e6cbd1c test 2023-03-17 14:04:42 +09:00
iFargle
88fd407d61 Ugh I need to pay attention. 2023-03-17 13:59:54 +09:00
iFargle
50289afc5c test 2023-03-17 13:56:22 +09:00
iFargle
716155996c test 2023-03-17 13:53:29 +09:00
iFargle
94e416afd1 Change variable name 2023-03-17 13:49:15 +09:00
iFargle
23f8cbc371 input escaping 2023-03-17 13:44:34 +09:00
iFargle
ece5a11aac Fix Python codescan alerts 2023-03-17 13:25:19 +09:00
iFargle
37f74ac82d More logging configs 2023-02-28 14:24:46 +09:00
iFargle
b610db3be5 Test 2023-02-28 14:16:17 +09:00
iFargle
3c0d975d16 test 2023-02-28 14:13:41 +09:00
iFargle
84683197d0 Reorder 2023-02-28 14:09:47 +09:00
iFargle
bba6f8d23e Test 2023-02-28 14:08:58 +09:00
iFargle
1eb6819390 Test 2023-02-28 14:01:55 +09:00