lixinsso

package module
v0.0.0-...-f08c4f1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 7 Imported by: 0

README

用于上海立信会计金融学院sso登录的模块

User

New(username string, password string) *User

初始化一个用户对象,用于保存用户基本模型,即用户名和密码。

(*User)Login() bool

使用user模型登录sso。

Authorize

Authorize用于在获取sso授权,包括登录sso和利用sso登录(授权)。其中授权sso中应用需要三个参数:client id, responseType以及redirect uri都在Authorize结构体中。这三个参数可以从其链接中获得。而state参数主要为了安全,而sso使用固定的1qw23e是不具备安全性能的,因此我无视了此参数。

例如: 学工系统:https://sso.lixin.edu.cn/authorize.php?client_id=ufsso_hairun_saass&redirect_uri=http://saass.lixin.edu.cn/redirect.aspx&response_type=code&state=success 其中的参数一目了然。

NewAuthorize(clientId string, responseType int, redirectURI string) *Authorize

初始化一个Authorize对象。其中responseType是Code或者Type的常量,定义在authorize.go中。

(*Authorize) Authorize(user *User) bool

进行授权操作,user可选。这里的授权操作包括自身sso的登录,因此可能需要用到user。如果无须用户名和密码,则user可以置nil。

(*Authorize)AuthorizeAPP(checkFunc func() bool ) bool

进行sso中应用的授权,不可用于sso自身登录。其中checkFunc可选,用于检验APP是否授权成功的函数。如果无须检验,置nil。

Documentation

Index

Constants

View Source
const (
	Token = 1
	Code  = 2
)

Restore the authorize type

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorize

type Authorize struct {
	// contains filtered or unexported fields
}

Authorize struct defines the basic parameter which needed in authorize url.

func NewAuthorize

func NewAuthorize(clientId string, responseType int, redirectURI string) *Authorize

NewAuthorize function builds a new authorize object.

func (*Authorize) Authorize

func (auth *Authorize) Authorize(u *User) bool

Authorize function make a request to the authorize url, according to the parameters in the Authorize struct. The function not only can authorize token type request, but also code one. If the responseType is "code", the parameter user can be nil. The code authorize use session to authorize.

func (*Authorize) AuthorizeApp

func (auth *Authorize) AuthorizeApp(checkFunc func() bool) bool

AuthorizeApp function authorize a specific APP. The usage can infer the example. checkFunc parameter is used to whether the specific app is authorized. The parameter can be nil.

type User

type User struct {
	// contains filtered or unexported fields
}

User struct define a user model. Everything can be done by the username and password.

func New

func New(username string, password string) *User

New function can create a new user object, with parameters username and password

func (*User) Login

func (user *User) Login() bool

Login to the sso.

Jump to

Keyboard shortcuts

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