aboutsummaryrefslogtreecommitdiff
path: root/overview.md
blob: 6b01e3e86026334dc12cc9f86320c90d9d8f994c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

   

Overview

back to index

Base URL

The server listens on http://<host>:<port>. Port is configurable, no specific port is required by the spec. but it is advised to use 5777 for internal purposes and 80/443 for External Purposes, If you want HTTPS you need a reverse proxy in front.

Content Type

Everything is JSON (Derulo bahahahahah). Requests and always responses use Content-Type: application/json.

The only exception is when a toolkit endpoint uses response_format: "passthrough" for proxying file downloads or something none Jayson from an upstream service. In that case the response mimetype comes from whatever upstream decides to send back.

Toolkit and Config file Format :

  • All config and toolkit files should use toml
  • If you hate toml for whatever reason you can use whatever you want in your implementation with the following two conditions being bundled with the server :
    • Built in support for converting the fully speced out reference server's config (SeckelAPI) to your implementations config format
    • Built in support for converting to fully compatible reference server's (SeckelAPI) toml files from your implementation config format
  • I dont want to make your life pain with this but just like give users the freedom of using a different backend server with ease if one ever comes. (might even happen from my side as seckel api is tbh a bit of a mess lol)

Authentication

Every endpoint requires a session token except these three:

  • GET / version info
  • GET /health service and DB status
  • POST /auth/login where you get a damn session token in the first place

Therefore to talk with JsonDerulo get a session token from /auth/login and send it on every request after that as Authorization: Bearer <token> it's the only way JsonDerulo wants to talk to you!

All Ways to talk to JsonDerulo (Endpoints)

Method Path Auth What it does
GET / no version info and stuff
GET /health no service health and DB connectivity
POST /auth/login no get a magic session token
POST /auth/logout yes kill your session :(
GET /auth/status yes check if your session is still alive
POST /auth/clear-sessions yes adminier: nuke all sessions for a specific user
POST /query yes database queries (select insert update delete count)
GET /permissions yes see what tables and columns you can access
POST /preferences yes get/set/reset user preferences
POST /reload yes adminier: hot/hard reload server config
POST/GET /tk/app/{toolkit}/{*path} yes toolkit application endpoint
POST/GET /tk/lib/{toolkit}/{*path} yes toolkit library endpoint

Rate Limiting

Backend should support two separate rate limiters: one for auth routes and one for API routes. Both are per IP with per second and per minute burst limits and should be capable of detecting external IP addresses (if behind proxi)

When you get rate limited the JsonDerulo responds with HTTP 429 and a JSON body telling you how long you should simply admire Jaysons Body instead of telling him your Schizophrenic JsonDerulo request, body should look like this:

{
  "success": false,
  "error": "Too many requests. Naughty! Go sit in a corner for 3 Seconds!",
  "retry_after": 3
}

Rate limiting can be disabled entirely in config but that shouldnt be done in production obviously.

Date and Time Formats

Query responses serialize the upstream database types into JSON like this:

MySQL Type JSON Format
DATE YYYY-MM-DD
DATETIME YYYY-MM-DD HH:MM:SS
TIMESTAMP RFC 3339 string
TIME HH:MM:SS
BOOLEAN / TINYINT(1) true / false

(I thought I implemented changing them but idk TODO in v2.1)

Request IDs

Every request gets a unique request_id. It shows up in error messages and audit logs so you can trace stuff if something goes wrong. The length of the request_id is capped at 32 Numbers and shouldnt be shorter than like 8)

Example :

{"message":"Session expired or invalid [request_id: 10036480868868238719]","success":false}

Request Body Limits

Theres should be configurable max request body size (in KB/MB/GB). Requests bigger than that get rejected. There should however be options to extend this for individual toolkit endpoints if nececsary.