Crates.io | casdoor-rust-sdk |
lib.rs | casdoor-rust-sdk |
version | 1.3.0 |
source | src |
created_at | 2022-07-02 11:41:32.905277 |
updated_at | 2023-09-27 08:45:56.020036 |
description | Rust client SDK for Casdoor |
homepage | https://casdoor.org |
repository | https://github.com/casdoor/casdoor-rust-sdk |
max_upload_size | |
id | 617744 |
size | 43,800 |
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.
[dependencies]
casdoor-rust-sdk = <latest-version>
Initialization requires 6 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 |
app_name | No | The name for the Casdoor application |
// init from params.
let app = CasdoorConfig::new(endpoint, client_id, client_secret, certificate, org_name);
// init from toml file, file_path should be absolute path. (recommend)
let conf = CasdoorConfig::from_toml(file_path).unwrap().as_str()).unwrap();
Now provide two services: CasdoorUserService
, CasdoorAuthService
You can create them like:
let user_service = UserService::new(&conf);
let auth_src = AuthService::new(&conf);
The SDK support basic operations.
user
get_user(name)
, get one user by user name.get_users()
, get all users.get_sorted_users(sorter, limit)
, get sorted user and limit number of result.get_user_count(is_online)
, get user count.add_user(User)
, write user to database.update_user(User)
, update user infodelete_user(User)
, delete userauth
get_auth_token(code)
, get the auth token.parse_jwt_token(token)
, parse jwt token.