GithubHelp home page GithubHelp logo

casdoor / casdoor-cpp-sdk Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 3.0 140 KB

C++ client SDK for Casdoor

Home Page: https://github.com/casdoor/casdoor

License: Apache License 2.0

C++ 100.00%
auth authentication authn c casdoor cpp iam oauth oidc sdk sso

casdoor-cpp-sdk's Introduction

casdoor-cpp-sdk

Discord

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

Step1. Init SDK

Initialization requires 5 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
CasdoorConfig casdoorConfig = new CasdoorConfig(endpoint, client_id, client_secret, certificate, org_name);

Step2. Get token and parse

After Casdoor verification passed, it will be redirected to your application with code and state, like https://forum.casbin.com/callback?code=xxx&state=yyyy.

Your web application can get the code and call GetOAuthToken(code=code), then parse out jwt token.

string access_token = casdoorConfig.GetOAuthToken(code)
strin user_json = casdoorConfig.ParseJwtToken(access_token)

user_json is the JSON data decoded from the access_token, which contains user info and other useful stuff.

Step3. Interact with the users

In casdoor-cpp-sdk, CasdoorConfig support basic user operations, like:

  • GetUsers() : Get all users.
  • GetUser(string user_id): get single user by user name.
  • ModifyUser(string method, CasdoorUser user)/AddUser(string method, CasdoorUser user)/UpdateUser(string method, CasdoorUser user)/DeleteUser(string method, CasdoorUser user) : modify user entry in database.

casdoor-cpp-sdk's People

Contributors

cs1137195420 avatar hsluoyz avatar leoil avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

casdoor-cpp-sdk's Issues

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.