Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/casdoor/casdoor-cpp-sdk
C++ client SDK for Casdoor
https://github.com/casdoor/casdoor-cpp-sdk
auth authentication authn c casdoor cpp iam oauth oidc sdk sso
Last synced: 2 months ago
JSON representation
C++ client SDK for Casdoor
- Host: GitHub
- URL: https://github.com/casdoor/casdoor-cpp-sdk
- Owner: casdoor
- License: apache-2.0
- Created: 2022-06-18T07:02:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-12T18:43:04.000Z (over 1 year ago)
- Last Synced: 2024-02-22T12:37:50.020Z (11 months ago)
- Topics: auth, authentication, authn, c, casdoor, cpp, iam, oauth, oidc, sdk, sso
- Language: C++
- Homepage: https://github.com/casdoor/casdoor
- Size: 137 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# casdoor-cpp-sdk
[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/5rPsrAzK7S)
This is Casdoor's SDK for C++, which will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.
Casdoor SDK is very simple to use. We will show you the steps below.
## Step1. Init SDK
Initialization requires 5 parameters, which are all string type:
| Name (in order) | Must | Description |
| --------------- | ---- | --------------------------------------------------- |
| endpoint | Yes | Casdoor Server Url, such as `http://localhost:8000` |
| client_id | Yes | Client ID for the Casdoor application |
| client_secret | Yes | Client secret for the Casdoor application |
| certificate | Yes | x509 certificate content of Application.cert |
| org_name | Yes | The name for the Casdoor organization |```cpp
CasdoorConfig casdoorConfig = new CasdoorConfig(endpoint, client_id, client_secret, certificate, org_name);```
## Step2. Get token and parse
After Casdoor verification passed, it will be redirected to your application with code and state, like https://forum.casbin.com/callback?code=xxx&state=yyyy.
Your web application can get the `cod`e and call `GetOAuthToken(code=code)`, then parse out jwt token.
```cpp
string access_token = casdoorConfig.GetOAuthToken(code)
strin user_json = casdoorConfig.ParseJwtToken(access_token)
```
`user_json` is the JSON data decoded from the access_token, which contains user info and other useful stuff.## Step3. Interact with the users
In casdoor-cpp-sdk, `CasdoorConfig` support basic user operations, like:
* `GetUsers()` : Get all users.
* `GetUser(string user_id)`: get single user by user name.
* `ModifyUser(string method, CasdoorUser user)/AddUser(string method, CasdoorUser user)/UpdateUser(string method, CasdoorUser user)/DeleteUser(string method, CasdoorUser user)` : modify user entry in database.