{"id":20215582,"url":"https://github.com/casdoor/casdoor-cpp-qt-example","last_synced_at":"2025-09-22T01:31:32.801Z","repository":{"id":104353579,"uuid":"532454922","full_name":"casdoor/casdoor-cpp-qt-example","owner":"casdoor","description":"C++ Qt desktop app example for Casdoor based on: https://github.com/casdoor/casdoor-cpp-sdk","archived":false,"fork":false,"pushed_at":"2023-07-21T03:51:35.000Z","size":1132,"stargazers_count":3,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T12:51:09.365Z","etag":null,"topics":["auth","authentication","c","casdoor","cpp","desktop","iam","oauth","oidc","qt","sso"],"latest_commit_sha":null,"homepage":"https://github.com/casdoor/casdoor","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casdoor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-09-04T06:13:43.000Z","updated_at":"2025-03-30T03:09:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"592fd64e-cec9-4b32-818a-0e6f9f71a9ed","html_url":"https://github.com/casdoor/casdoor-cpp-qt-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/casdoor/casdoor-cpp-qt-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-cpp-qt-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-cpp-qt-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-cpp-qt-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-cpp-qt-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casdoor","download_url":"https://codeload.github.com/casdoor/casdoor-cpp-qt-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-cpp-qt-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276333824,"owners_count":25624044,"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","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["auth","authentication","c","casdoor","cpp","desktop","iam","oauth","oidc","qt","sso"],"created_at":"2024-11-14T06:23:22.603Z","updated_at":"2025-09-22T01:31:31.932Z","avatar_url":"https://github.com/casdoor.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"border-bottom: none;\"\u003e📦⚡️casdoor cpp qt example\u003c/h1\u003e\r\n\u003ch3 align=\"center\"\u003eAn example of casdoor-cpp-sdk\u003c/h3\u003e\r\n\r\n## Architecture\r\n\r\nExample contains 2 parts:\r\n\r\n| Name     | SDK              | Language         | Source code                                                     |\r\n| -------- | ---------------- | ---------------- | --------------------------------------------------------------- |\r\n| Frontend | Qt SDK  | Qt | https://github.com/casdoor/casdoor-cpp-qt-example |\r\n| Backend  | casdoor-cpp-sdk | c++             | https://github.com/casdoor/casdoor-cpp-sdk                |\r\n\r\n## Demo\r\n\r\n   \u003cimg src=\".\\doc\\fig\\casdoor_cpp_qt.gif\" style=\"zoom: 67%;\" /\u003e\r\n\r\n## Supported Enviroments (Tested)\r\n\r\nThis example is tested on the following envrioments: \r\n\r\n| System      | Qt | Compiler |\r\n| :------ | ---- | ---- |\r\n| Win10/Win11 | Qt5.15 | MSVC 2019 |\r\n| Ubuntu 22.04 | Qt 6.4 | gcc |\r\n\r\n\r\n\r\n## Installation\r\n\r\nExample uses Casdoor to manage members. So you need to create an organization and an application for the example in a Casdoor instance.\r\n\r\n### Get the code\r\n\r\n```shell\r\ngit clone https://github.com/casdoor/casdoor\r\ngit clone https://github.com/casdoor/casdoor-cpp-qt-example\r\n```\r\n\r\n### Windows\r\n\r\nWindows11 + MSVC 2019 + Qt 5.15\r\n\r\nOn Windows, the module `QtWebEngine`  used in this demo is only available under MSVC 2017 or MSVC 2019.\r\n\r\n1. Install MSVC 2019:\r\n\r\n    [Build Tools for Visual Studio 2019](https://my.visualstudio.com/Downloads?q=visual studio 2019\u0026wt.mc_id=o~msft~vscom~older-downloads)\r\n\r\n   [Visual C++ Redistributable for Visual Studio 2019](https://my.visualstudio.com/Downloads?q=visual studio 2019\u0026wt.mc_id=o~msft~vscom~older-downloads)\r\n\r\n   \r\n\r\n2. Install Qt: using Qt Online installer:\r\n\r\n   `[Get and Install Qt with Qt Online Installer](https://doc.qt.io/qt-6/qt-online-installation.html)\r\n\r\n   use mirror to download Qt: `.\\qt-unified-windows-x86-online.exe --mirror https://mirrors.ustc.edu.cn/qtproject`\r\n\r\n3. Add include path in `.pro` file. \r\n    ```qt\r\n    // in ./casdoor-cpp-qt-example.pro\r\n    INCLUDEPATH += $$quote(D:/Program Files/OpenSSL-Win64/include) // installation path of OpenSSL\r\n    ```\r\n\r\n### Linux\r\n\r\nUbuntu22.04 + gcc + Qt6.4.3\r\n\r\n1. Install Qt\r\n\r\n   `[Get and Install Qt with Qt Online Installer](https://doc.qt.io/qt-6/qt-online-installation.html)\r\n\r\n   use mirror to download Qt: `.\\qt-unified-windows-x86-online.exe --mirror https://mirrors.ustc.edu.cn/qtproject`\r\n\r\n2. Install Openssl\r\n\r\n   Install from Source\r\n\r\n   ```shell\r\n   git clone git://git.openssl.org/openssl.git\r\n   cd openssl\r\n   ./Configure --prefix=/usr/local/openssl\r\n   make \u0026\u0026 make install\r\n   ```\r\n\r\n3. Modify Include Path/File \r\n\r\n   ```cpp\r\n   // in ./casdoor-cpp-qt-example.pro\r\n   INCLUDEPATH += \"/user/local/openssl/include/openssl\" // installation path of OpenSSL\r\n   \r\n   // in mainwindow.h add\r\n   #include \u003cQTcpSocket\u003e\r\n   ```\r\n   \r\n   \r\n   \r\n\r\n### Configure Application in Casdoor\r\n\r\n1. Setup your Casdoor Applicaiton\r\n\r\n   Set redirect URL for your Applicaiotn :  eg. `http://localhost:11000/callback`\r\n\r\n   Remember the `Client ID` and `Client secert` in the Application page\r\n\r\n   \r\n   \u003cimg src=\".\\doc\\fig\\clientID.png\" style=\"zoom:80%;\" /\u003e\r\n   \r\n   Copy the public `Certificate` in the Cert page.\r\n   \r\n   \u003cimg src=\".\\doc\\fig\\cert.png\" style=\"zoom:66%;\" /\u003e\r\n\r\n### Configure  Casdoor SDK\r\n\r\n1. Configure SDK\r\n   \r\n    ```cpp\r\n    // in ./mainwindow.h\r\n    std::string endpoint = \"http://localhost:7001\"; //front-end\r\n    std::string client_id = \"3386b5767bbedeecd9d9\";\r\n    std::string client_secret = \"2a576a2fc4293d5da8f10e1e42399fc973a50ba6\";\r\n    std::string certificate = R\"(-----BEGIN CERTIFICATE-----\r\n    -----END CERTIFICATE-----)\";\r\n    std::string org_name = \"casbin-forum\";\r\n    std::string app_name = \"app-qt\";\r\n    std::string redirect_url = \"http://localhost:11000/callback\";\r\n    std::string response_type = \"code\";\r\n    std::string scope = \"read\";\r\n    ```\r\n    \r\n    \r\n    ```cpp\r\n    // in ./mainwindow.cpp\r\n    \r\n    // MainWindow::initTcpServer\r\n    m_tcpserver-\u003elisten(QHostAddress::LocalHost, 8080); // port where tcp server listen\r\n    \r\n    // MainWindow::on_auth_code_received\r\n    if(url.toString().startsWith(\"http://localhost:11000/callback\"))  // redirect_url\r\n    ```\r\n    \r\n    \r\n    ```cpp\r\n    // in ./mainwindow.cpp\r\n    CasdoorConfig* casdoor = new CasdoorConfig(\r\n        \"http://localhost:7001\", // Casdoor Frontend Url\r\n        \"3efd29ff3e0b14ba1dd7\", // client id\r\n        \"34cb65d634b06a49f14c6bc49884ce1df55ce518\", // client secret\r\n        cert, // certificate\r\n        \"built-in\" // organization\r\n    );\r\n    ```\r\n\r\n\r\n5. Run Qt Application in QtCreater\r\n\r\n\r\n   \u003cimg src=\".\\doc\\fig\\casdoor_cpp_qt.gif\" style=\"zoom: 67%;\" /\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-cpp-qt-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasdoor%2Fcasdoor-cpp-qt-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-cpp-qt-example/lists"}