The backend (server) for TermFTP built with Java
The general request path is as follows: <ip>:<port>/api/v1
Endpoints
- POST:
api/v1/register - POST:
api/v1/login - POST:
api/v1/createServer - GET:
api/v1/serverGroups - POST:
api/v1/group - PUT:
api/v1/updateServer - DELETE:
api/v1/removeServerFromGroup - DELETE:
api/v1/removeGroup - DELETE:
api/v1/removeServer - GET:
api/v1/confirm-account - DELETE:
api/v1/deleteUser - POST:
api/v1/connection - GET:
api/v1/connections - GET:
api/v1/settings - POST:
api/v1/settings - DELETE:
api/v1/deleteSettings
This endpoint is used to create a new user (register). Hereby, a verification email will be sent to the users email address. As soon as the user opens the link, the field verified changes to true.
-
URI:
api/v1/register -
Type:
POST -
Body: a simplified version of the
Userobject{ "username" : "user1", "password" : "a_pw", "email" : "[email protected]" }- Note:
emailmust be unique!
- Note:
-
Response-Body:
DefaulResponewith the newly created user{ "status": 200, "message": "Created User", "data": { "username": "user1", "email": "[email protected]", "userID": "6293eed0-cbb7-4d7b-97df-49f45dc98528", "verified": false } }
This endpoint is used to login a user. After a successful login, this endpoint returns a unique Access-Token that required for many other endpoints.
-
URI:
api/v1/login -
Type:
POST -
Headers:
PC-Name:the-name-of-someones-pc
-
Body
{ "username" : "user1", "password" : "a_pw" } -
Response-Body:
DefaulResponewith the latestAccess-Token{ "status": 200, "message": "AccessToken", "data": { "accessTokenID": { "token": "pzklzntrphjrabczvbxilzhoitggyaqi", "userID": "6293eed0-cbb7-4d7b-97df-49f45dc98528" }, "validUntil": "2021-04-02", "pcName": "morpheus" } }
This endpoint is used to create a single server.
-
URI:
api/v1/createServer -
Type:
POST -
Headers:
Access-Token:<access-token>
-
Body
{ "ip" : "127.0.0.3", "ftpPort" : "21", "sshPort" : "22", "name" : "local2", "username" : "admin", "password" : "admin" } -
Response-Body:
DefaulResponewith the createdServer{ "status": 200, "message": "Created Server", "data": { "serverID": "39957cfc-54e9-4347-939f-c976df1ff289", "ip": "127.0.0.3", "ftpPort": 21, "sshPort": 22, "lastConnection": null, "name": "local2", "username": "admin", "password": "admin" } }
This endpoint is used to retrieve the whole tree of server groups (and sub-groups) with the containing servers PER USER.
-
URI:
api/v1/serverGroups -
Type:
GET -
Headers:
Access-Token:<access-token>
-
Response-Body:
DefaulResponewith the tree ofServerGroups (list){ "status": 200, "message": "Server-Groups", "data": [ { "groupID": "839fad77-e6e5-4751-a6a2-803ca56f61af", "name": "default", "userID": "6293eed0-cbb7-4d7b-97df-49f45dc98528", "serverGroups": [], "server": [ { "serverID": "39957cfc-54e9-4347-939f-c976df1ff289", "ip": "127.0.0.3", "ftpPort": 21, "sshPort": 22, "lastConnection": null, "name": "local2", "username": "admin", "password": "admin" } ] }, { "groupID": "e1e81224-c73e-4e68-933e-657368f6f2d8", "name": "favourites", "userID": "6293eed0-cbb7-4d7b-97df-49f45dc98528", "serverGroups": [], "server": [] } ] }
This endpoint is used to create or change server groups. You can either create empty groups, sub-groups or groups with servers. Additionally this endpoints lets you change the name of the group or add further servers to it.
-
URI:
api/v1/group -
Type:
POST -
Headers:
Access-Token:<access-token>
-
Body
-
Create an empty group
- Note: When creating a new group, don't send any
groupID(otherwise the existing group with that ID will be renamed)
{ "groupID" : null, "name" : "empty-group-01", "groups" : null, "servers" : null } - Note: When creating a new group, don't send any
-
Add a sub-group
- Important
- The sub group needs to be created first
- The ID of the sub-group must not be the same as the parent
groupID
groupID... parent groupgroups... an array of sub-groups (which must already exist)
{ "groupID" : "363855af-7aca-4ab0-951b-6411a0c345b6", "name" : null, "groups" : ["987855af-kd8454ab0-851c-7511a1c375c8"], "servers" : null } - Important
-
Create a group with servers in it
- Note: When creating a new group, don't send any
groupID(otherwise the existing group with that ID will be renamed)
{ "groupID" : null, "name" : "work", "groups" : null, "servers" : ["39957cfc-54e9-4347-939f-c976df1ff289"] } - Note: When creating a new group, don't send any
-
Rename a group
- Note: When renaming a group, both the
groupIDand thenamemust be given
{ "groupID" : "39957cfc-54e9-4347-939f-c976df1ff289", "name" : "work", "groups" : null, "servers" : ["39957cfc-54e9-4347-939f-c976df1ff289"] } - Note: When renaming a group, both the
-
-
Response-Body:
DefaulResponewith the created/changedServerGroup{ "status": 200, "message": "Server-Group", "data": { "groupID": "363855af-7aca-4ab0-951b-6411a0c345b6", "name": "work", "userID": "6293eed0-cbb7-4d7b-97df-49f45dc98528", "serverGroups": [], "server": [ { "serverID": "39957cfc-54e9-4347-939f-c976df1ff289", "ip": "127.0.0.3", "ftpPort": 21, "sshPort": 22, "lastConnection": null, "name": "local2", "username": "admin", "password": "admin" } ] } }- this is a response of Create a group with servers in it
This endpoint is used to update a single server.
-
URI:
api/v1/updateServer -
Type:
PUT -
Headers:
Access-Token:<access-token>
-
Body: the updated
Serverobject{ "serverID" : "39957cfc-54e9-4347-939f-c976df1ff289", "ip" : "127.0.0.11", "ftpPort" : 21, "sshPort" : 22, "username" : "admin", "password" : "nowthereisastrongerpw" } -
Response-Body:
DefaulResponewith the updatedServer{ "status": 200, "message": "Updated Server", "data": { "serverID": "39957cfc-54e9-4347-939f-c976df1ff289", "ip": "127.0.0.11", "ftpPort": 21, "sshPort": 22, "lastConnection": null, "name": null, "username": "admin", "password": "nowthereisastrongerpw" } }
This endpoint is used to remove a single Serverfrom a ServerGroup
-
URI:
api/v1/removeServerFromServerGroup -
Type:
DELETE -
Headers:
Access-Token:<access-token>
-
Request-Params:
serverID:<id-of-the-server>groupID:<id-of-the-group>
-
Response-Body:
DefaulResponewith status{ "status": 200, "message": "Removed 1 server from serverGroup.", "data": true }
This endpoint is used to remove a wholeServerGroup
-
URI:
api/v1/removeGroup -
Type:
DELETE -
Headers:
Access-Token:<access-token>
-
Request-Params:
groupID:<id-of-the-group>
-
Response-Body:
DefaulResponewith status{ "status": 200, "message": "Removed 1 serverGroup.", "data": true }
This endpoint is used to remove a single Server
-
URI:
api/v1/removeServer -
Type:
DELETE -
Headers:
Access-Token:<access-token>
-
Request-Params:
serverID:<id-of-the-server>
-
Response-Body:
DefaulResponewith status{ "status": 200, "message": "Removed 1 server.", "data": true }
This endpoint is used to remove a single Server
-
URI:
api/v1/confirm-account -
Type:
GET -
Headers:
Access-Token:<access-token>
-
Request-Params:
token:<confirmation-token>
-
Response-Body:
DefaulResponewith status{ "status": 200, "message": "Verification", "data": true }
This endpoint is used to delete a single User
-
URI:
api/v1/deleteUser -
Type:
DELETE -
Headers:
Access-Token:<access-token>
-
Response-Body:
DefaulResponewith status{ "status": 200, "message": "Deleted User", "data": 1 }
This endpoint saves a connection (aka HistoryItem)
-
URI:
api/v1/connection -
Type:
POST -
Headers:
Access-Token:<access-token>
-
Request-Body:
HistoryItem{ "device" : "my private pc", "ip" : "127.0.0.25", "sshPort" : 22, "ftpPort" : 21, "username" : "admin" } -
Response-Body:
DefaultResponsewith the savedHistoryItem{ "status": 200, "message": "Saved HistoryItem (=Connection)", "data": { "historyItemID": { "userID": "2a2cac53-056b-4cac-af29-756fdfefcf21", "when": "2021-04-08T14:14:02.930337" }, "device": "my private pc", "ip": "127.0.0.25", "deleted": false, "sshPort": 22, "ftpPort": 21, "username": "admin" } }
This endpoint returns the complete history of a user's connections.
-
URI:
api/v1/connections -
Type:
GET -
Headers:
Access-Token:<access-token>
-
Response-Body:
DefaultResponsewith the history (list ofHistoryItem){ "status": 200, "message": "List of Connections (HistoryItems) aka 'vErLaUf'", "data": [ { "historyItemID": { "userID": "2a2cac53-056b-4cac-af29-756fdfefcf21", "when": "2021-04-08T14:14:02.930337" }, "device": "my private pc", "ip": "127.0.0.25", "deleted": false, "sshPort": 22, "ftpPort": 21, "username": "admin" }, { "historyItemID": { "userID": "2a2cac53-056b-4cac-af29-756fdfefcf21", "when": "2021-04-08T14:19:33.108154" }, "device": "my other pc", "ip": "127.0.0.26", "deleted": false, "sshPort": 22, "ftpPort": 21, "username": "admin" } ] }
This endpoint returns all settings of one user.
-
URI:
api/v1/settings -
Type:
GET -
Headers:
Access-Token:<access-token>
-
Response-Body:
DefaultResponsewith the list ofSimpleSettings{ "status": 200, "message": "All settings for user u1", "data": [ { "settingID": "key2", "value": "value2" }, { "settingID": "key1", "value": "value1" } ] }
This endpoint saves - or if they already exist, updates - the given settings
-
URI:
api/v1/settings -
Type:
POST -
Headers:
Access-Token:<access-token>
-
Request-Body:
List<SimpleSetting>[ { "settingID" : "key1", "value" : "value1" }, { "settingID" : "key2", "value" : "value2" } ] -
Response-Body:
DefaultResponsewith the list ofSimpleSettings{ "status": 200, "message": "Saved 2 settings.", "data": [ { "settingID": { "userID": "ce210960-b092-42e6-9e37-4edc288e17e2", "settingID": "key1" }, "value": "value1" }, { "settingID": { "userID": "ce210960-b092-42e6-9e37-4edc288e17e2", "settingID": "key2" }, "value": "value2" } ] }
This endpoint deletes the given settings identified by their key (``settingID`). If a setting with the given ID does not exist, it will be ignored.
-
URI:
api/v1/deleteSettings -
Type:
DELETE -
Headers:
Access-Token:<access-token>
-
Request-Body:
List<String>(list of keys)[ "key1", "key3" ] -
Response-Body:
DefaultResponsewith the number of deleted settings.{ "status": 200, "message": "Deleted Settings for user u1", "data": 1 }