Giter VIP home page Giter VIP logo

casdoor-rust-sdk's Introduction

casdoor-rust-sdk

GitHub last commit Crates.io Docs CI Discord

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>

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
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();

Step2. Get service and use

Now provide two services: CasdoorUserService, CasdoorAuthService

You can create them like:

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

Step3. Interact with the sdk services

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 info
  • delete_user(User), delete user

auth

  • get_auth_token(code), get the auth token.
  • parse_jwt_token(token), parse jwt token.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.