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.

casdoor-rust-sdk's People

Contributors

actions-user avatar hsluoyz avatar leavelet avatar qianxi0410 avatar selflocking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

casdoor-rust-sdk's Issues

Design a better way to modify user and adding unit tests for them

Modifying user contains three methods: add, update, and delete.
Now, updating user workflow is like this: get user by name -> modify some info -> use update_user function to modify it.
Then, how do we add a user? is specify id a must? what information are needed? how can we verify this? I don't come up with a good idea so far, and the other SDKs do not provide good examples in their docs too.
So I hope sometime we can fix this.

JWT parsing keeps failing due to InvalidKeyFormat error after invoking parse_jwt_token()

I've been trying to set up a working example on localhost for nextjs oauth with rust on the backend. I'm using the casdoor-rust-sdk to fetch the signup/signin uri which mostly works but when I try to authorize and fetch the JWT token from the rust backend I'm constantly being reminded of the InvalidKeyFormat error despite my conf.toml file being correctly formed (as per rust-sdk-example project)

I triple checked that the pub_key from the certs page in the dashboard is correct along with the generated certificate being assigned to the test application.

Is this a bug or am I missing something. Been at it for 3 hours.
Screenshot 2023-07-13 at 15 39 19

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Unable to build workspace dependencies graph: Unable to parse the workspace structure starting at /home/runner/work/casdoor-rust-sdk/casdoor-rust-sdk/Cargo.toml

Unfortunately this error doesn't have any additional information. Feel free to kindly ask the author of the @semantic-release/exec plugin to add more helpful information.


Good luck with your project ✨

Your semantic-release bot 📦🚀

upload the crate to crates.io

Uploading this crate to crates.io will make using it much easier. Maybe we can do this after our first stable release.

Will using a single version of fmt tool be a good idea?

I noticed that the workflow will use all fmt tools from stable, beta and nightly version. But cargo fmt tool will change from version to version, and the result may be variable. So will it be a good idea to just use a single version of fmt tool?

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Unable to build workspace dependencies graph: Unable to parse the workspace structure starting at /home/runner/work/casdoor-rust-sdk/casdoor-rust-sdk/Cargo.toml

Unfortunately this error doesn't have any additional information. Feel free to kindly ask the author of the @semantic-release/exec plugin to add more helpful information.


Good luck with your project ✨

Your semantic-release bot 📦🚀

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.