casdoor-rust-sdk

GitHub last commit Crates.io Docs CI Gitter

This is Casdoor's SDK for Rust, 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.

toml [dependencies] casdoor-rust-sdk = <latest-version>

Step1. Init SDK

Initialization requires 6 parameters, which are all string type:

| Name (in order) | Must | Description | | --------------- | ---- | --------------------------------------------------- | | endpoint | Yes | Casdoor Server Url, such as http://localhost:8000 | | clientid | Yes | Client ID for the Casdoor application | | clientsecret | Yes | Client secret for the Casdoor application | | jwtpubkey | Yes | The public key for the Casdoor application's cert | | orgname | Yes | The name for the Casdoor organization | | appname | No | The name for the Casdoor application |

```rust // init from params. let app = CasdoorConfig::new(endpoint, clientid, clientsecret, certificate, org_name);

// init from toml file, filepath should be absolute path. (recommend) let conf = CasdoorConfig::fromtoml(filepath).unwrap().asstr()).unwrap(); ```

Step2. Get service and use

Now provide two services: CasdoorUserService, CasdoorAuthService

You can create them like:

rust let user_service = UserService::new(&conf); let auth_src = AuthService::new(&conf);

Step3. Interact with the sdk services

The SDK support basic operations.

user

auth