casdoorsdk

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddApplication

func AddApplication(application *Application) (bool, error)

func AddOrganization

func AddOrganization(organization *Organization) (bool, error)

func AddUser

func AddUser(user *User) (bool, error)

func CheckUserPassword

func CheckUserPassword(user *User) (bool, error)

func DeleteApplication

func DeleteApplication(name string) (bool, error)

func DeleteOrganization

func DeleteOrganization(name string) (bool, error)

func DeleteResource

func DeleteResource(name string) (bool, error)

func DeleteUser

func DeleteUser(user *User) (bool, error)

func DoGetBytes

func DoGetBytes(url string) ([]byte, error)

DoGetBytes is a general function to get response from param url through HTTP Get method.

func DoGetBytesRaw

func DoGetBytesRaw(url string) ([]byte, error)

DoGetBytesRaw is a general function to get response from param url through HTTP Get method.

func GetMyProfileUrl

func GetMyProfileUrl(accessToken string) string

func GetOAuthToken

func GetOAuthToken(code string, state string) (*oauth2.Token, error)

GetOAuthToken gets the pivotal and necessary secret to interact with the Casdoor server

func GetSigninUrl

func GetSigninUrl(redirectUri string) string

func GetSignupUrl

func GetSignupUrl(enablePassword bool, redirectUri string) string

func GetUrl

func GetUrl(action string, queryMap map[string]string) string

func GetUserCount

func GetUserCount(isOnline string) (int, error)

func GetUserProfileUrl

func GetUserProfileUrl(userName string, accessToken string) string

func InitConfig

func InitConfig(endpoint string, clientId string, clientSecret string, certificate string, organizationName string, applicationName string)

func RefreshOAuthToken

func RefreshOAuthToken(refreshToken string) (*oauth2.Token, error)

RefreshOAuthToken refreshes the OAuth token

func SendEmail

func SendEmail(title string, content string, sender string, receivers ...string) error

func SendSms

func SendSms(content string, receivers ...string) error

func UpdateUser

func UpdateUser(user *User) (bool, error)

func UpdateUserForColumns

func UpdateUserForColumns(user *User, columns []string) (bool, error)

func UploadResource

func UploadResource(user string, tag string, parent string, fullFilePath string, fileBytes []byte) (string, string, error)

func UploadResourceEx

func UploadResourceEx(user string, tag string, parent string, fullFilePath string, fileBytes []byte, createdTime string, description string) (string, string, error)

Types

type Application

type Application struct {
	Owner       string `json:"owner"`
	Name        string `json:"name"`
	CreatedTime string `json:"createdTime"`

	DisplayName         string `json:"displayName"`
	HomepageUrl         string `json:"homepageUrl"`
	Description         string `json:"description"`
	Organization        string `json:"organization"`
	Cert                string `json:"cert"`
	EnablePassword      bool   `json:"enablePassword"`
	EnableSignUp        bool   `json:"enableSignUp"`
	EnableSigninSession bool   `json:"enableSigninSession"`
	EnableCodeSignin    bool   `json:"enableCodeSignin"`

	ClientId             string   `json:"clientId"`
	ClientSecret         string   `json:"clientSecret"`
	RedirectUris         []string `json:"redirectUris"`
	TokenFormat          string   `json:"tokenFormat"`
	ExpireInHours        int      `json:"expireInHours"`
	RefreshExpireInHours int      `json:"refreshExpireInHours"`
	SignupUrl            string   `json:"signupUrl"`
	SigninUrl            string   `json:"signinUrl"`
	ForgetUrl            string   `json:"forgetUrl"`
	AffiliationUrl       string   `json:"affiliationUrl"`
	TermsOfUse           string   `json:"termsOfUse"`
	SignupHtml           string   `json:"signupHtml"`
	SigninHtml           string   `json:"signinHtml"`
}

Application has the same definition as https://github.com/casdoor/casdoor/blob/master/object/application.go#L24

type AuthConfig

type AuthConfig struct {
	Endpoint         string
	ClientId         string
	ClientSecret     string
	Certificate      string
	OrganizationName string
	ApplicationName  string
}

AuthConfig is the core configuration. The first step to use this SDK is to use the InitConfig function to initialize the global authConfig.

type Claims

type Claims struct {
	User
	AccessToken string `json:"accessToken"`
	jwt.RegisteredClaims
}

func ParseJwtToken

func ParseJwtToken(token string) (*Claims, error)

type Organization

type Organization struct {
	Owner       string `json:"owner"`
	Name        string `json:"name"`
	CreatedTime string `json:"createdTime"`

	DisplayName        string `json:"displayName"`
	WebsiteUrl         string `json:"websiteUrl"`
	Favicon            string `json:"favicon"`
	PasswordType       string `json:"passwordType"`
	PasswordSalt       string `json:"passwordSalt"`
	PhonePrefix        string `json:"phonePrefix"`
	DefaultAvatar      string `json:"defaultAvatar"`
	MasterPassword     string `json:"masterPassword"`
	EnableSoftDeletion bool   `json:"enableSoftDeletion"`
}

Organization has the same definition as https://github.com/casdoor/casdoor/blob/master/object/organization.go#L25

type Permission

type Permission struct {
	Action       string   `json:"action"`
	Actions      []string `json:"actions"`
	CreatedTime  string   `json:"createdTime"`
	DisplayName  string   `json:"displayName"`
	Effect       string   `json:"effect"`
	IsEnabled    bool     `json:"isEnabled"`
	Name         string   `json:"name"`
	Owner        string   `json:"owner"`
	ResourceType string   `json:"resourceType"`
	Resources    []string `json:"resources"`
	Roles        []string `json:"roles"`
	Users        []string `json:"users"`
}

func GetPermission

func GetPermission() ([]*Permission, error)

type Resource

type Resource struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

Resource has the same definition as https://github.com/casdoor/casdoor/blob/master/object/resource.go#L24

type Response

type Response struct {
	Status string      `json:"status"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
	Data2  interface{} `json:"data2"`
}

func AddPermission

func AddPermission(q Permission) (*Response, error)

type User

type User struct {
	Owner       string `json:"owner"`
	Name        string `json:"name"`
	CreatedTime string `json:"createdTime"`
	UpdatedTime string `json:"updatedTime"`

	Id                string   `json:"id"`
	Type              string   `json:"type"`
	Password          string   `json:"password"`
	PasswordSalt      string   `json:"passwordSalt"`
	DisplayName       string   `json:"displayName"`
	Avatar            string   `json:"avatar"`
	PermanentAvatar   string   `json:"permanentAvatar"`
	Email             string   `json:"email"`
	Phone             string   `json:"phone"`
	Location          string   `json:"location"`
	Address           []string `json:"address"`
	Affiliation       string   `json:"affiliation"`
	Title             string   `json:"title"`
	IdCardType        string   `json:"idCardType"`
	IdCard            string   `json:"idCard"`
	Homepage          string   `json:"homepage"`
	Bio               string   `json:"bio"`
	Tag               string   `json:"tag"`
	Region            string   `json:"region"`
	Language          string   `json:"language"`
	Gender            string   `json:"gender"`
	Birthday          string   `json:"birthday"`
	Education         string   `json:"education"`
	Score             int      `json:"score"`
	Karma             int      `json:"karma"`
	Ranking           int      `json:"ranking"`
	IsDefaultAvatar   bool     `json:"isDefaultAvatar"`
	IsOnline          bool     `json:"isOnline"`
	IsAdmin           bool     `json:"isAdmin"`
	IsGlobalAdmin     bool     `json:"isGlobalAdmin"`
	IsForbidden       bool     `json:"isForbidden"`
	IsDeleted         bool     `json:"isDeleted"`
	SignupApplication string   `json:"signupApplication"`
	Hash              string   `json:"hash"`
	PreHash           string   `json:"preHash"`

	CreatedIp      string `json:"createdIp"`
	LastSigninTime string `json:"lastSigninTime"`
	LastSigninIp   string `json:"lastSigninIp"`

	Github   string `json:"github"`
	Google   string `json:"google"`
	QQ       string `json:"qq"`
	WeChat   string `json:"wechat"`
	Facebook string `json:"facebook"`
	DingTalk string `json:"dingtalk"`
	Weibo    string `json:"weibo"`
	Gitee    string `json:"gitee"`
	LinkedIn string `json:"linkedin"`
	Wecom    string `json:"wecom"`
	Lark     string `json:"lark"`
	Gitlab   string `json:"gitlab"`

	Ldap       string            `json:"ldap"`
	Properties map[string]string `json:"properties"`
}

User has the same definition as https://github.com/casdoor/casdoor/blob/master/object/user.go#L24

func GetSortedUsers

func GetSortedUsers(sorter string, limit int) ([]*User, error)

func GetUser

func GetUser(name string) (*User, error)

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

func GetUserByPhone

func GetUserByPhone(phone string) (*User, error)

func GetUserByUserId

func GetUserByUserId(userId string) (*User, error)

func GetUsers

func GetUsers() ([]*User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL