config

package
v0.1.81 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigInterface

type ConfigInterface interface {
	// contains filtered or unexported methods
}

type CookieConfig

type CookieConfig struct {
	Domain   string
	Path     string
	Secure   bool
	HttpOnly bool
	SameSite string
}

func DefaultCookieConfig

func DefaultCookieConfig() *CookieConfig

type FileConfig

type FileConfig struct {
	TokenConfig *TokenConfig
}

func ReadConfig added in v0.0.6

func ReadConfig(confName string) (*FileConfig, error)

ReadConfig create from file.

type SignConfig added in v0.0.6

type SignConfig struct {
	SecretKey string
	// nonce exist time
	TimeStampDisparity int64
	IsCheckNonce       bool
}

SignConfig sign config

func NewSignConfig added in v0.0.6

func NewSignConfig(options *SignOptions) (*SignConfig, error)

func (*SignConfig) GetSaveNonceExpire added in v0.0.6

func (s *SignConfig) GetSaveNonceExpire() int64

type SignOptions added in v0.0.6

type SignOptions struct {
	SecretKey          string
	TimeStampDisparity int64
	IsCheckNonce       bool
}

SignOptions SignConfig options

type SsoConfig added in v0.0.6

type SsoConfig struct {

	// Mode sso mode
	Mode string
	// TicketTimeout ticket timeout
	TicketTimeout int64
	// AllowUrl All allowed authorization callback addresses, separated by ','
	AllowUrl string
	IsSlo    bool
	IsHttp   bool

	// SSO-Client current client name
	Client string
	// SSO-Server auth url
	AuthUrl string
	// SSO-Server check ticket url
	CheckTicketUrl string
	GetDataUrl     string
	UserInfoUrl    string
	SloUrl         string
	SsoLogoutCall  string

	ServerUrl string

	/**
	sso callback func
	*/
	// NotLoginView
	NotLoginView func() interface{}

	// DoLoginHandle login func
	DoLoginHandle func(name string, pwd string, ctx ctx.Context) (interface{}, error)

	// TicketResultHandle called each time the result of the validation ticket is obtained from the SSO-Server
	TicketResultHandle func(loginId string, back string) (interface{}, error)

	// SendHttp sent http
	SendHttp func(url string) (string, error)
}

func DefaultSsoConfig added in v0.0.6

func DefaultSsoConfig(serverUrl string, notLoginView func() interface{},
	doLoginHandle func(name string, pwd string, ctx ctx.Context) (interface{}, error),
	ticketResultHandle func(o1 string, s string) (interface{}, error),
	sendHttp func(url string) (string, error)) *SsoConfig

func NewSsoConfig added in v0.0.6

func NewSsoConfig(options *SsoOptions) (*SsoConfig, error)

func (*SsoConfig) SetAllow added in v0.0.6

func (c *SsoConfig) SetAllow(urls ...string) *SsoConfig

SetAllow set allow callback url

func (*SsoConfig) SpliceAuthUrl added in v0.0.6

func (c *SsoConfig) SpliceAuthUrl() string

SpliceAuthUrl return Server-side single sign-on authorization address

func (*SsoConfig) SpliceCheckTicketUrl added in v0.0.6

func (c *SsoConfig) SpliceCheckTicketUrl() string

SpliceCheckTicketUrl return ticket verification address on the server side

func (*SsoConfig) SpliceGetDataUrl added in v0.0.6

func (c *SsoConfig) SpliceGetDataUrl() string

func (*SsoConfig) SpliceSloUrl added in v0.0.6

func (c *SsoConfig) SpliceSloUrl() string

func (*SsoConfig) SpliceUserInfoUrl added in v0.0.6

func (c *SsoConfig) SpliceUserInfoUrl() string

type SsoOptions added in v0.0.6

type SsoOptions struct {
	CookieDomain string

	// Mode sso mode
	Mode string
	// TicketTimeout ticket timeout
	TicketTimeout int64
	// AllowUrl All allowed authorization callback addresses, separated by ','
	AllowUrl string
	IsSlo    bool
	IsHttp   bool

	// SSO-Client current client name
	Client string
	// SSO-Server auth url
	AuthUrl string
	// SSO-Server check ticket url
	CheckTicketUrl string
	GetDataUrl     string
	UserInfoUrl    string
	SloUrl         string
	SsoLogoutCall  string

	ServerUrl string

	/**
	sso callback func
	*/
	// NotLoginView
	NotLoginView func() interface{}

	// DoLoginHandle login func
	DoLoginHandle func(name string, pwd string, ctx ctx.Context) (interface{}, error)

	// TicketResultHandle called each time the result of the validation ticket is obtained from the SSO-Server
	TicketResultHandle func(loginId string, back string) (interface{}, error)

	// SendHttp sent http
	SendHttp func(url string) (string, error)
}

SsoOptions new SsoConfig options.

type TokenConfig

type TokenConfig struct {
	// TokenStyle
	// uuid | uuid-simple | random-string32 | random-string64 | random-string128
	TokenStyle string
	// TokenName prefix
	TokenPrefix string
	TokenName   string

	Timeout int64

	// If you enable DoubleToken, returns double token - token and refreshToken, when token is timeout, you can use refreshToken to refreshToken to auto login.
	DoubleToken         bool
	RefreshTokenName    string
	RefreshTokenTimeout int64

	// If last operate time < ActivityTimeout, token expired
	ActivityTimeout int64
	// Data clean period
	DataRefreshPeriod int64
	// Auto refresh token
	AutoRenew bool

	// Allow multi login
	IsConcurrent bool
	// Multi login share same token
	IsShare bool
	// If (IsConcurrent == true && IsShare == false), support MaxLoginCount
	// If IsConcurrent == -1, do not need to check loginCount
	MaxLoginCount int16
	// Maximum number of logins per device
	DeviceMaxLoginCount int16

	// Read token method
	// Set to true to read token from these method before login.
	IsReadBody   bool
	IsReadHeader bool
	// If IsReadCookie is set to true, a cookie will be set after successful login
	IsReadCookie bool

	// Write token to response header.
	// Set to true to write after login.
	IsWriteHeader bool

	TokenSessionCheckLogin bool

	JwtSecretKey string

	CurDomain string

	SameTokenTimeout int64

	CheckSameToken bool

	CookieConfig *CookieConfig
}

func DefaultTokenConfig

func DefaultTokenConfig() *TokenConfig

func (*TokenConfig) InitConfig added in v0.1.7

func (t *TokenConfig) InitConfig()

Jump to

Keyboard shortcuts

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