Expand description
Casdoor’s SDK for Rust, it lets an application use Casdoor as its authentication and authorization system, without having to implement one from scratch.
Everything is done through the Client, which is created from the config of a
Casdoor application:
use casdoor_rust_sdk::Client;
let client = Client::new(
"http://localhost:8000",
"<client-id>",
"<client-secret>",
"<certificate>",
"built-in",
"app-built-in",
);
// Redirect the user to this URL to sign in.
let signin_url = client.get_signin_url("http://localhost:9000/callback");
// In the callback, exchange the code for an access token and read the user.
let token = client.get_oauth_token("<code>").await?;
let claims = client.parse_jwt_token(&token.access_token)?;
println!("signed in as {}", claims.user.name);
// Call the APIs as the application itself.
let users = client.get_users().await?;The SDK is kept in sync with the Go SDK, one Rust module per Go file, so that the two are easy to compare.
Structs§
- Account
Item - Adapter
- Adapter has the same definition as https://github.com/casdoor/casdoor/blob/master/object/adapter.go.
- Address
- Application
- Application has the same definition as https://github.com/casdoor/casdoor/blob/master/object/application.go.
- Auth
Config - AuthConfig is the core configuration of the SDK, it has the same fields as the
AuthConfigstruct of the Casdoor Go SDK. - Casbin
Rule - CasbinRule is one policy rule stored by a Casbin adapter. Its JSON fields are capitalized, as the Casbin xorm adapter defines them without JSON tags.
- Cert
- Cert has the same definition as https://github.com/casdoor/casdoor/blob/master/object/cert.go.
- Claims
- Claims is the payload of the JWT token issued by Casdoor, it embeds the
Userthe token was issued to. - Client
- Client is the Casdoor client, it holds the config of the Casdoor application and sends all the API requests to the Casdoor server.
- Consent
Record - Enforcer
- Enforcer has the same definition as https://github.com/casdoor/casdoor/blob/master/object/enforcer.go.
- FaceId
- Group
- Group has the same definition as https://github.com/casdoor/casdoor/blob/master/object/group.go.
- Header
- Introspect
Token Result - The result of the RFC 7662 token introspection.
- Invitation
- Invitation has the same definition as https://github.com/casdoor/casdoor/blob/master/object/invitation.go.
- JwtItem
- Ldap
- Ldap has the same definition as https://github.com/casdoor/casdoor/blob/master/object/ldap.go.
- Ldap
User - One user read from an LDAP server.
- Ldap
Users Response - The response of
Client::get_ldap_users(). - Managed
Account - MfaAccount
- MfaInitiate
Data - The data of the response of
Client::initiate_mfa(). - MfaItem
- MfaProps
- MfaRequest
- Model
- Model has the same definition as https://github.com/casdoor/casdoor/blob/master/object/model.go.
- OAuth
Token - The OAuth token returned by the Casdoor server.
- Order
- Order has the same definition as https://github.com/casdoor/casdoor/blob/master/object/order.go.
- Organization
- Organization has the same definition as https://github.com/casdoor/casdoor/blob/master/object/organization.go.
- Payment
- Payment has the same definition as https://github.com/casdoor/casdoor/blob/master/object/payment.go.
- Permission
- Permission has the same definition as https://github.com/casdoor/casdoor/blob/master/object/permission.go.
- Permission
Rule - PermissionRule has the same definition as https://github.com/casdoor/casdoor/blob/master/object/permission_rule.go.
- Plan
- Plan has the same definition as https://github.com/casdoor/casdoor/blob/master/object/plan.go.
- Policy
Filter - A filter used by
Client::get_filtered_policies(). - Pricing
- Pricing has the same definition as https://github.com/casdoor/casdoor/blob/master/object/pricing.go.
- Product
- Product has the same definition as https://github.com/casdoor/casdoor/blob/master/object/product.go.
- Product
Info - One product of an
Order. - Provider
- Provider has the same definition as https://github.com/casdoor/casdoor/blob/master/object/provider.go.
- Provider
Item - Record
- Record has the same definition as https://github.com/casdoor/casdoor/blob/master/object/record.go.
- Resource
- Resource has the same definition as https://github.com/casdoor/casdoor/blob/master/object/resource.go.
- Response
- Response is the general response returned by the Casdoor server APIs.
- Role
- Role has the same definition as https://github.com/casdoor/casdoor/blob/master/object/role.go.
- Saml
Item - Scope
Description - Scope
Item - Session
- Session has the same definition as https://github.com/casdoor/casdoor/blob/master/object/session.go.
- Signin
Item - Signin
Method - Signup
Item - Subscription
- Subscription has the same definition as https://github.com/casdoor/casdoor/blob/master/object/subscription.go.
- Sync
Ldap Users Response - The response of
Client::sync_ldap_users(). - Syncer
- Syncer has the same definition as https://github.com/casdoor/casdoor/blob/master/object/syncer.go.
- Table
Column - Theme
Data - Third
Party Link - Token
- Token has the same definition as https://github.com/casdoor/casdoor/blob/master/object/token.go.
- Transaction
- Transaction has the same definition as https://github.com/casdoor/casdoor/blob/master/object/transaction.go.
- User
- User has the same definition as https://github.com/casdoor/casdoor/blob/master/object/user.go.
- Userinfo
- The user info returned by the OIDC
/api/userinfoAPI. - Webhook
- Webhook has the same definition as https://github.com/casdoor/casdoor/blob/master/object/webhook.go.
Enums§
- Casdoor
Error - The error type returned by all the SDK APIs.
- Post
Body - The body of a POST request sent to the Casdoor server.
Constants§
- CASDOOR_
APPLICATION - The name of the built-in Casdoor application.
- CASDOOR_
ORGANIZATION - The name of the built-in Casdoor organization.
- MFA_
RECOVERY_ CODES_ SESSION - The name of the session that holds the MFA recovery codes.
- MFA_
TYPE_ APP - The MFA type of an authenticator app (TOTP).
- MFA_
TYPE_ EMAIL - The MFA type sent by email.
- MFA_
TYPE_ SMS - The MFA type sent by SMS.
- SUB_
STATE_ ACTIVE - The subscription is running.
- SUB_
STATE_ ERROR - The subscription failed.
- SUB_
STATE_ EXPIRED - The subscription has ended.
- SUB_
STATE_ PENDING - The subscription is waiting for its payment.
- SUB_
STATE_ SUSPENDED - The subscription was suspended by the admin.
- SUB_
STATE_ UPCOMING - The subscription has not started yet.
Functions§
- get_
current_ time - Get the current time in RFC 3339 format (UTC), e.g.
2026-01-02T15:04:05Z, which is the format Casdoor uses for fields likecreated_time.
Type Aliases§
- Casbin
Request - A Casbin request, such as
["alice", "data1", "read"]. - Casdoor
Config Deprecated - The old name of
AuthConfig, kept to ease the migration from the 1.x versions. - Casdoor
User Deprecated - The old name of
User, kept to ease the migration from the 1.x versions. - Result
- The result type returned by all the SDK APIs.