{"id":18772746,"url":"https://github.com/sctg-development/sctgdesk-api-server","last_synced_at":"2026-01-05T04:05:20.561Z","repository":{"id":237998609,"uuid":"795533647","full_name":"sctg-development/sctgdesk-api-server","owner":"sctg-development","description":"API server for rustdesk in Rust","archived":false,"fork":false,"pushed_at":"2024-05-22T17:43:28.000Z","size":661,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T18:46:59.613Z","etag":null,"topics":["rustdesk","rustdesk-api-server"],"latest_commit_sha":null,"homepage":"https://sctg-development.github.io/sctgdesk-api-server/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sctg-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-03T13:40:32.000Z","updated_at":"2024-05-31T10:58:17.673Z","dependencies_parsed_at":"2024-05-22T18:45:30.375Z","dependency_job_id":"b6b7ed6a-e3e5-421f-923c-796085b2f611","html_url":"https://github.com/sctg-development/sctgdesk-api-server","commit_stats":null,"previous_names":["sctg-development/sctgdesk-api-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fsctgdesk-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fsctgdesk-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fsctgdesk-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fsctgdesk-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sctg-development","download_url":"https://codeload.github.com/sctg-development/sctgdesk-api-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244728199,"owners_count":20500023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rustdesk","rustdesk-api-server"],"created_at":"2024-11-07T19:30:04.301Z","updated_at":"2026-01-05T04:05:20.555Z","avatar_url":"https://github.com/sctg-development.png","language":"TypeScript","funding_links":["https://github.com/sponsors/sctg-development"],"categories":[],"sub_categories":[],"readme":"* Integrated server: [![Full server](https://github.com/sctg-development/sctgdesk-server/actions/workflows/multiarch-docker-hub.yml/badge.svg)](https://github.com/sctg-development/sctgdesk-server/actions/workflows/multiarch-docker-hub.yml)  \n* Standalone nightly build: [![Build and Deploy](https://github.com/sctg-development/sctgdesk-api-server/actions/workflows/build.yaml/badge.svg)](https://github.com/sctg-development/sctgdesk-api-server/actions/workflows/build.yaml)\n\n[**Download full server**](https://github.com/sctg-development/sctgdesk-server/releases)  \n[**API Documentation**](https://sctg-development.github.io/sctgdesk-api-server/)  \n\n![](https://tokeisrv.sctg.eu.org/b1/github.com/sctg-development/sctgdesk-api-server?type=Rust,TypeScript,TSX,C\u0026category=code)\n![](https://tokeisrv.sctg.eu.org/b1/github.com/sctg-development/sctgdesk-api-server?type=TSX,Rust,TypeScript\u0026category=comments) \n\n# sctgdesk-api-server\n\n## Star the project\n\n**If you appreciate my work, please consider giving it a star! 🤩** or a [![](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/sctg-development)\n\n## Disclaimer\n\nFirst of all this project was not developped to be a replacement of Rustdesk-server-pro. It was developped for our requirements and to be used with Rustdesk.  \nSo there is no warranty, no support, no guarantee, no liability.  \nThe target use it to be included as a crate in rustdesk-server.  \nAs the rustdesk-server was published under AGPL-3.0, this project is also published under AGPL-3.0. That's why you see it !  \nFeel free to use it, modify it, but don't forget to publish your modifications.  \n\n## Description\n\nThis project, sctgdesk-api-server, is a basic implementation of an API server for Rustdesk. Rustdesk is an open-source remote control software. This implementation is written in Rust, utilizing the Rocket framework. The entire REST API is documented using `rocket_okapi`. Upon launching the server, it serves Rapidoc module at `/api/doc`, which allows visualizing and testing the various API routes. The server is configured to listen on port 21114. It is designed to utilize a SQLite3 database compatible with the Rustdesk-server or Rustdesk-server-pro databases.\n\n## Status\n\nThe server is currently under development and is not yet ready for production use.\n\n## Licensing\n\nThis server is distributed under the terms of the GNU Affero General Public License version 3.0 (AGPL-3.0).\n\n## Features\n\n* API server for Rustdesk\n* New address book API\n  * Support for personal address book\n  * Support for shared address book at group level\n    * read-only, read-write, admin\n  * Support for shared address book at user level\n    * read-only, read-write, admin\n* OpenAPI documentation\n* Web console (work in progress)\n\n## Architecture\n\nThe server use Rocket as the web framework. The server is designed to be modular and extensible. The server is divided into three main parts:\n\n* The `api` module contains the API routes and the API logic. It is 100% Rust code with Rocket framework.\n* The `webconsole` module contains the web console. It is a single page Vue.js application written in Typescript. The API is automatically generated from the OpenAPI with Swagger codegen for Axios Typescript. You can access the web console at `/ui`. You'll find the code in the `webconsole` directory.\n* The `openapi` module contains the OpenAPI documentation. It is generated with `rocket_okapi`. You can access the Rapidoc module at `/api/doc`.\n\n## Authentication\n\nThe server includes basic support for authentication with a username and password. Passwords are stored in the database after being hashed with bcrypt. Additionally, similar to Rustdesk-server-pro, it supports authentication with third-party providers compatible with OAuth2. Currently, only Github and Dex (as a custom provider) are available. For adding a new provider you must implement the `OAuthProvider` and `OAuthProviderFactory` traits. You can look at the [github_provider.rs](https://github.com/sctg-development/sctgdesk-api-server/blob/main/libs/oauth2/src/github_provider.rs) and [dex_provider.rs](https://github.com/sctg-development/sctgdesk-api-server/blob/main/libs/oauth2/src/dex_provider.rs) files for examples.  \nThe first time you launch the server it will create a default user with the username `admin` and the password `Hello,world!`. You can change the password after the first login on the webconsole.\n\n### Default admin user\n\nThe default admin user is created with the username `admin` and the password `Hello,world!`. You can change the password after the first login on the webconsole.\n\n## S3 url generation\n\nOur custom clients are stored in a S3 bucket. The S3 configuration is stored in the `s3config.toml` file. The server generates a signed URL for the client download. The URL is valid for 5 minutes. The server generates download links at:\n\n* `/api/software/client-download-link/\u003ckey\u003e` for the client download\n  * key can be one of osx w64 or ios\n\n## Configuration\n\nThe server requires an `oauth2.toml` configuration file to function. By default, it is expected at `./oauth2.toml`, although this location can be modified using the `OAUTH2_CONFIG_FILE` environment variable. Setting the `OAUTH2_CREATE_USER` variable to `1` enables the automatic creation of a user upon the first OAuth2 login. The user is created with the Rustdesk ID and a random password, which is displayed in the server logs.  \nThe server also requires a `s3config.toml` configuration file to function. By default, it is expected at `./s3config.toml`, although this location can be modified using the `S3_CONFIG_FILE` environment variable. The S3 configuration file is used to configure the S3 storage for the server.  \nIf you don't provide this two files, the server will create them for you in the working directory.\n\n## OpenAPI\n\nThe server is designed to be fully documented using OpenAPI. The documentation is generated using `rocket_okapi`. The server serves the Rapidoc module at `/api/doc`, which allows visualizing and testing the various API routes.  \nObviously without any test possible a Rapidoc server is deployed at [https://sctg-development.github.io/sctgdesk-api-server/](https://sctg-development.github.io/sctgdesk-api-server/)  \nThe typescript client api is autogenerated with `swagger-codegen.sh`\n\n## Web console\n\nA web console is available at `/ui` it is a work in progress and is not yet ready for production use.  \nIt is a stub for the future sctgdesk-api-server web console.  \nThe choosen framework is Vue.js. The API is automatically generated from the OpenAPI with Swagger codegen for Axios Typescript. Note the codegen is not yet ready for production use and a few modifications are needed.  \nFor regenerating the api code, run the following command **after** the server is running (it needs docker to be running):\n\n```bash\n./swagger-codegen.sh\n```\n\n### Development\n\nTo start the ui development server, run the following commands:\n\n```bash\nsqlite3 db_v2.sqlite3 \u003c\u003cEOF\nINSERT OR IGNORE INTO peer (guid, id, uuid, pk, created_at, \"user\", status, note, region, strategy, info, last_online) VALUES\n  (x'018f255622f77778a006702ca5c23715', 'TESTUSER', randomblob(16), randomblob(16), '1901-01-01 12:00:00', randomblob(16), 0, '', NULL, randomblob(16), '{}', '1901-01-01 12:00:00');\nEOF\ncargo build\ncd webconsole \u0026\u0026 npm ci \u0026\u0026 npm run devserver \u0026\ncd ..\nVITE_DEVELOPMENT=\"http://localhost:5173\" target/debug/sctgdesk-api-server\n```\n\nIt will start a nodejs ui development server on port 5173. Sctgdesk-api-server will proxy the requests to ui development server rather than serving embedded static files. Access the development ui at `http://localhost:21114/ui` .\n\nEach time you modify the code, the server will automatically rebuild and reload the ui development server.\n\n## Standalone API server\n\nThe server can be run as a standalone server. To run the server, execute the following command:\n\nIn  development mode:\n\n```bash\nDATABASE_URL=sqlite://$(pwd)/db_v2.sqlite3 cargo run --release\n```\n\nIn production mode:\n\n```bash\nsctgdesk-api-server --help\nRuns the SCTGDesk API Server\n\nUsage: sctgdesk-api-server [OPTIONS]\n\nOptions:\n      --address \u003cADDRESS\u003e        Sets the address for the server [default: 127.0.0.1]\n      --port \u003cPORT\u003e              Sets the port for the server [default: 21114]\n      --log_level \u003cLOG_LEVEL\u003e    Sets the log level for the server [default: debug]\n      --secret_key \u003cSECRET_KEY\u003e  Sets the secret key for the server [default: wJq+s/xvwZjmMX3ev0p4gQTs9Ej5wt0brsk3ZGhoBTg=]\n  -h, --help                     Print help\n  -V, --version                  Print version\n```\n\n## Screenshots\n\n### Webconsole\n\n\u003cimg width=\"1085\" alt=\"login\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/fe72a374-8a98-4606-8632-3d919f9317c9\"\u003e\n\n\u003cimg width=\"1285\" alt=\"dashboard\" src=\"https://github.com/sctg-development/sctgdesk-api-server/assets/165936401/0bb148d6-8723-491f-88c5-b98331d64f61\"\u003e\n\n\u003cimg width=\"1085\" alt=\"devices\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/6ae55861-f65c-4950-a068-f22eef3ad81a\"\u003e\n\n\u003cimg width=\"1084\" alt=\"users\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/8d225841-43f5-44f4-8d41-5b6ca3324096\"\u003e\n\n\u003cimg width=\"1087\" alt=\"groups\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/d84ce3d3-1d19-4765-883f-001f313a4a1e\"\u003e\n\n\u003cimg width=\"1089\" alt=\"address books\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/db13010b-077a-4e14-943b-9d8de3266f82\"\u003e\n\n\u003cimg width=\"730\" alt=\"rues\" src=\"https://github.com/sctg-development/sctgdesk-api-server/assets/165936401/3a990deb-d8bb-4725-a47d-435ec3667fee\"\u003e\n\n\u003cimg width=\"621\" alt=\"add rules\" src=\"https://github.com/sctg-development/sctgdesk-api-server/assets/165936401/355f3903-2b54-4b08-abd0-e33c84a260ed\"\u003e\n\n### Api documentation\n\n\u003cimg width=\"1502\" alt=\"apidoc\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/88fe7910-fe62-43e5-a16c-70dc1201e040\"\u003e\n\n### Use in Rustdesk client\n\n\u003cimg width=\"913\" alt=\"Capture d’écran 2024-05-24 à 12 14 34\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/1b253577-dce2-4163-9a49-ba4b3da37812\"\u003e\n\n\u003cimg width=\"923\" alt=\"Capture d’écran 2024-05-24 à 12 07 21\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/c49b3aba-b13f-4b15-a69c-d492a90e774a\"\u003e\n\n\u003cimg width=\"927\" alt=\"Capture d’écran 2024-05-24 à 12 07 32\" src=\"https://github.com/sctg-development/sctgdesk-server/assets/165936401/f447f5fa-bc77-4bc6-858a-c6cadf9b7f6c\"\u003e\n\n## Building\n\nFirst you need to install the Rust toolchain. You can install it by following the instructions at [https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install).\n\nYou also need to install the SQLite3 development libraries. On Ubuntu, you can install them with the following command:\n\n```bash\nsudo apt install libsqlite3-dev\n```\n\non MacOS:\n\n```bash\nbrew install sqlite3\n```\n\non Windows:\n\n```bash\nchoco install sqlite\n```\n\nYou also need nodejs and npm to build the webconsole. You can install them by following the instructions at [https://nodejs.org/en/download/](https://nodejs.org/en/download/).\n\nTo build the server on *nix, execute the following command:\n\n```bash\nDATABASE_URL=sqlite://$(pwd)/db_v2.sqlite3 \u0026\u0026 cargo build --release\n```\n\nTo build the server on Windows, execute the following command:\n\n```bash\nset \"DATABASE_URL=sqlite://%CD%/db_v2.sqlite3\" \u0026\u0026 cargo build --release --target x86_64-pc-windows-msvc\n```\n\n## Integration with Rustdesk-Server\n\nThe server can be integrated with the Rustdesk-server you can easily integrate it by modifying the [main.rs](https://github.com/sctg-development/sctgdesk-server/blob/tcpserver-master-build/src/main.rs) file of the Rustdesk-server. :\n\n```rust\nuse sctgdesk_api_server::build_rocket;\n\n#[rocket::main]\nasync fn start_rocket() -\u003e ResultType\u003c()\u003e {\n    let port = get_arg_or(\"port\", RENDEZVOUS_PORT.to_string()).parse::\u003ci32\u003e()?;\n    let figment = rocket::Config::figment()\n        .merge((\"address\", \"0.0.0.0\"))\n        .merge((\"port\", port-2))\n        .merge((\"log_level\", LogLevel::Debug))\n        .merge((\"secret_key\", \"wJq+s/xvwZjmMX3ev0p4gQTs9Ej5wt0brsk3ZGhoBTg=\"))\n        .merge((\"limits\", Limits::new().limit(\"json\", 2.mebibytes())));\n    let _rocket = build_rocket(figment).await.ignite().await?.launch().await?;\n    Ok(())\n}\n```\n\nand in the `main` function:\n\n```rust\n    let rocket_thread = thread::spawn(|| {\n        let _ = start_rocket();\n    });\n\n    RendezvousServer::start(port, serial, \u0026get_arg(\"key\"), rmem)?;\n    let _ = rocket_thread.join();\n    Ok(())\n```\n\nYou can look at the [sctgdesk-server main.rs](https://github.com/sctg-development/sctgdesk-server/blob/tcpserver-master-build/src/main.rs) for a working itegration.\n\n### Integrated API server with Rustdesk-Server\n\nif you want a ready to use integrated server with Rustdesk-Server, you can use my own server [sctgdesk-server](https://github.com/sctg-development/sctgdesk-server). Binaries are available at [release page](https://github.com/sctg-development/sctgdesk-server/releases). Binaries are available for Linux Ubuntu 22.04LTS amd64 and arm64.\n\n## Limitations\n\n* The server is not yet ready for production use. Buy a [Rustdesk-server-pro](https://rustdesk.com/pricing.html) license to get a production-ready server.  \n* The Bearen tokens are stored in memory without persistence. It means that each time the server is restarted, all the tokens are lost. You will need to re-authenticate with the server.  \n\n## CLI Usage\n\n* User login:  \n  \n    ```bash\n    curl -X POST \"http://127.0.0.1:21114/api/login\" \\\n                    -H \"accept: application/json\"\\\n                    -H \"content-type: application/json\" \\\n                    -d '{\"username\":\"admin\",\"password\":\"Hello,world!\",\"id\":\"string\",\"uuid\":\"string\"}' \n        # Note the Bearen token in the response\n    ```\n\n* Create user:\n  \n    ```bash\n    curl -X POST \"http://127.0.0.1:21114/api/user\" \\\n                    -H \"accept: application/json\"\\\n                    -H \"authorization: Bearer viZ2ArJutFtKsg0DDC1TiV-87uSRQqGBZXAoCeHrFHc\"\\\n                    -H \"content-type: application/json\" \\\n                    -d '{\"name\":\"testuser\",\"password\":\"test\",\"confirm-password\":\"test\",\"email\":\"string\",\"is_admin\":false,\"group_name\":\"Default\"}' \n    ```\n\n* Use Rapidoc to test the API at \u003chttp://127.0.0.1:21114/api/doc\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fsctgdesk-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsctg-development%2Fsctgdesk-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fsctgdesk-api-server/lists"}