auth

package
v0.0.0-...-8c04c50 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FeishuAuthURL         = "https://open.feishu.cn/open-apis/authen/v1/index"
	FeishuTokenURL        = "https://open.feishu.cn/open-apis/authen/v1/access_token"
	FeishuRefreshTokenURL = "https://open.feishu.cn/open-apis/authen/v1/refresh_access_token"
	FeishuTenantTokenURL  = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
	FeishuUserGroupURL    = "https://open.feishu.cn/open-apis/contact/v3/group/member_belong"
)

Endpoint is feishu's endpoint url

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	Handler(ctx *fasthttp.RequestCtx, session Session, redirect SoftRedirect)
	Valid(session Session) bool
	GroupValid(hostName string, session Session, valid PipeGroupValid) bool
}

func New

func New(cfg *config.AuthConfig) (Auth, error)

New parse the auth block of the config file

type BaseAuth

type BaseAuth struct {
	BaseURL *url.URL
}

func (*BaseAuth) IsCallback

func (a *BaseAuth) IsCallback(ctx *fasthttp.RequestCtx) bool

func (*BaseAuth) RequestURL

func (a *BaseAuth) RequestURL(ctx *fasthttp.RequestCtx) string

type Fake

type Fake struct {
}

func (*Fake) GroupValid

func (f *Fake) GroupValid(hostName string, session Session, valid PipeGroupValid) bool

func (*Fake) Handler

func (f *Fake) Handler(ctx *fasthttp.RequestCtx, session Session, redirect SoftRedirect)

func (*Fake) Valid

func (f *Fake) Valid(session Session) bool

type Feishu

type Feishu struct {
	BaseAuth
	Config *config.AuthConfig
}

func (*Feishu) GroupValid

func (f *Feishu) GroupValid(hostName string, session Session, valid PipeGroupValid) bool

func (*Feishu) Handler

func (f *Feishu) Handler(ctx *fasthttp.RequestCtx, session Session, redirect SoftRedirect)

func (*Feishu) Valid

func (f *Feishu) Valid(session Session) bool

type FeishuAccessToken

type FeishuAccessToken struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		AccessToken  string `json:"access_token"`
		RefreshToken string `json:"refresh_token"`
		Name         string `json:"name"`
		EnName       string `json:"en_name"`
		OpenId       string `json:"open_id"`
		ExpiresIn    int64  `json:"expires_in"`
	} `json:"data"`
}

type FeishuTenantToken

type FeishuTenantToken struct {
	Code              int    `json:"code"`
	Msg               string `json:"msg"`
	TenantAccessToken string `json:"tenant_access_token"`
	Expire            int64  `json:"expire"`
}

type FeishuUserGroup

type FeishuUserGroup struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data struct {
		GroupList []string `json:"group_list,flow"`
		HasMore   bool     `json:"has_more"`
	} `json:"data"`
}

type OAuth2

type OAuth2 struct {
	BaseAuth
	Config *config.AuthConfig
}

func (*OAuth2) GroupValid

func (oauth *OAuth2) GroupValid(hostName string, session Session, valid PipeGroupValid) bool

func (*OAuth2) Handler

func (oauth *OAuth2) Handler(ctx *fasthttp.RequestCtx, session Session, redirect SoftRedirect)

func (*OAuth2) Valid

func (oauth *OAuth2) Valid(session Session) bool

type PipeGroupValid

type PipeGroupValid func(group string, hostName string) bool

type Session

type Session interface {
	Set(key string, value string)
	SetInt(key string, value int64)
	Get(key string) string
	GetInt(key string) int64
	Delete(key string)
	Expired(last int64) bool
}

type SoftRedirect

type SoftRedirect func(url string)

Jump to

Keyboard shortcuts

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