All Projects → casdoor → casdoor-go-sdk

casdoor / casdoor-go-sdk

Licence: Apache-2.0 license
Go client SDK for Casdoor

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to casdoor-go-sdk

casdoor
An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS, QQ group: 645200447
Stars: ✭ 4,147 (+11108.11%)
Mutual labels:  oauth, oidc, authn, casdoor
Idtoken Verifier
Lightweight RSA JWT verification
Stars: ✭ 52 (+40.54%)
Mutual labels:  oauth, auth
oidc
Easy to use OpenID Connect client and server library written for Go and certified by the OpenID Foundation
Stars: ✭ 475 (+1183.78%)
Mutual labels:  oauth, oidc
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+4597.3%)
Mutual labels:  oauth, auth
OpenAM
OpenAM is an open access management solution that includes Authentication, SSO, Authorization, Federation, Entitlements and Web Services Security.
Stars: ✭ 476 (+1186.49%)
Mutual labels:  oauth, oidc
Angular Token
🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:
Stars: ✭ 376 (+916.22%)
Mutual labels:  oauth, auth
Vue Authenticate
Simple Vue.js authentication library
Stars: ✭ 1,350 (+3548.65%)
Mutual labels:  oauth, auth
IdentityServer4.PhoneNumberAuth
Sample passwordless phone number authentication using OAuth in ASP.NET Core 2.2
Stars: ✭ 83 (+124.32%)
Mutual labels:  oauth, oidc
React Native Instagram Login
a react native instagram login component (support android & ios). Pull requests are welcome!
Stars: ✭ 139 (+275.68%)
Mutual labels:  oauth, auth
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+6178.38%)
Mutual labels:  oauth, oidc
Twitch4j
Modular Async/Sync/Reactive Twitch API Client / IRC Client
Stars: ✭ 209 (+464.86%)
Mutual labels:  oauth, auth
AzureADAuthRazorUiServiceApiCertificate
Azure AD flows using ASP.NET Core and Microsoft.Identity
Stars: ✭ 41 (+10.81%)
Mutual labels:  oauth, oidc
supabase-ui-svelte
Supabase authentication UI for Svelte
Stars: ✭ 83 (+124.32%)
Mutual labels:  oauth, auth
Next Auth
Authentication for Next.js
Stars: ✭ 8,362 (+22500%)
Mutual labels:  oauth, oidc
yii-auth-client
Yii Framework external authentication via OAuth and OpenID Extension
Stars: ✭ 20 (-45.95%)
Mutual labels:  oauth, auth
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (+110.81%)
Mutual labels:  oauth, auth
token-cli
Command line utility for interacting with OAuth2 infrastructure to generate tokens
Stars: ✭ 19 (-48.65%)
Mutual labels:  oidc, authn
okta-jhipster-microservices-oauth-example
A microservices architecture built with JHipster, OAuth 2.0, and Okta
Stars: ✭ 29 (-21.62%)
Mutual labels:  oauth, oidc
firebase auth oauth
A Flutter plugin that makes it easy to perform OAuth sign in flows using FirebaseAuth.
Stars: ✭ 28 (-24.32%)
Mutual labels:  oauth, auth
Hydra
OpenID Certified™ OpenID Connect and OAuth Provider written in Go - cloud native, security-first, open source API security for your infrastructure. SDKs for any language. Compatible with MITREid.
Stars: ✭ 11,884 (+32018.92%)
Mutual labels:  oauth, oidc

casdoor-go-sdk

semantic-release GitHub Workflow Status (branch) GitHub Release

Go Report Card license GitHub issues GitHub stars GitHub forks Gitter

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

Noted that this sdk has been applied to casnode, if you still don’t know how to use it after reading README.md, you can refer to it

Step1. Install and Import

First in your go project, just need to run:

go get github.com/casdoor/casdoor-go-sdk@latest

and import this when you need:

import "github.com/casdoor/casdoor-go-sdk/casdoorsdk"

Step2. Init Config

Initialization requires 6 parameters, which are all string type:

Name (in order) Must Description
endpoint Yes Casdoor server URL, such as http://localhost:8000
clientId Yes Application.clientId
clientSecret Yes Application.clientSecret
certificate Yes x509 certificate content of Application.cert
organizationName Yes Application.organization
applicationName Yes Application.applicationName
func InitConfig(endpoint string, clientId string, clientSecret string, certificate string, organizationName string, applicationName string)

Step3. Get token and parse

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

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

The general process is as follows:

token, err := casdoorsdk.GetOAuthToken(code, state)
if err != nil {
	panic(err)
}

claims, err := casdoorsdk.ParseJwtToken(token.AccessToken)
if err != nil {
	panic(err)
}

claims.AccessToken = token.AccessToken

Step4. Set Session in your app

auth.Claims contains the basic information about the user provided by casdoor, you can use it as a keyword to set the session in your application, like this:

data, _ := json.Marshal(claims)
c.setSession("user", data)

Step5. Interact with the users

Casdoor-go-sdk support basic user operations, like:

  • GetUser(name string), get one user by user name.
  • GetUsers(), get all users.
  • UpdateUser(casdoorsdk.User)/AddUser(casdoorsdk.User)/DeleteUser(casdoorsdk.User), write user to database.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].