web

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LimitArticle = 3
	LimitLinks   = 10
)
View Source
const (
	ERROR_DB       = 1
	ERROR_PARAM    = 2
	ERROR_INTERNAL = 3
	ERROR_LIMIT    = 4
)

Variables

View Source
var (
	// MsgPack is a Codec that uses the `ugorji/go/codec` package.
	MsgPack = scodec.Codec{Marshal: msgPackMarshal, Unmarshal: msgPackUnmarshal}
)

Functions

func AuthUserMiddleware added in v0.6.3

func AuthUserMiddleware(redirect bool) gin.HandlerFunc

func AvatarHTML added in v0.8.2

func AvatarHTML(s string) template.HTML

AvatarHTML 生成头像的HTML标签,目前仅支持微信头像

func DeleteTGC

func DeleteTGC(c *gin.Context)

func GetTGC

func GetTGC(c *gin.Context) *cas.Ticket

func IsAjax added in v0.6.3

func IsAjax(r *http.Request) bool

func LoadPrivateKey added in v0.12.4

func LoadPrivateKey(data []byte) (interface{}, error)

LoadPrivateKey loads a private key from PEM/DER data.

func New

func New(c Config) *server

New returns current server instance

func NewTGC

func NewTGC(c *gin.Context, ticket *cas.Ticket)

func RequestScheme added in v0.12.4

func RequestScheme(r *http.Request) string

func SessionLoad added in v0.8.1

func SessionLoad(r *http.Request) session.Session

func SessionSave added in v0.8.1

func SessionSave(sess session.Session, w http.ResponseWriter)

func SetBase added in v0.6.10

func SetBase(s string)

func UrlFor added in v0.6.10

func UrlFor(path string) string

func UserFromStaff

func UserFromStaff(staff *models.Staff) *auth.User

Types

type AccessTokenGenJWT

type AccessTokenGenJWT struct {
	Key []byte
}

AccessTokenGenJWT JWT access token generator

func (*AccessTokenGenJWT) GenerateAccessToken

func (c *AccessTokenGenJWT) GenerateAccessToken(data *osin.AccessData, generaterefresh bool) (accesstoken string, refreshtoken string, err error)

type Config added in v0.10.0

type Config struct {
	Addr    string
	Root    string
	FS      string
	BaseURI string
}

Config ...

type IDToken added in v0.12.4

type IDToken struct {
	Issuer     string `json:"iss"`
	UserID     string `json:"sub"`
	ClientID   string `json:"aud"`
	Expiration int64  `json:"exp"`
	IssuedAt   int64  `json:"iat"`

	Nonce string `json:"nonce,omitempty"` // Non-manditory fields MUST be "omitempty"

	Email         string `json:"email,omitempty"`
	EmailVerified *bool  `json:"email_verified,omitempty"`

	UID        string `json:"uid,omitempty"`
	Name       string `json:"name,omitempty"`
	FamilyName string `json:"family_name,omitempty"`
	GivenName  string `json:"given_name,omitempty"`
	Locale     string `json:"locale,omitempty"`

	BirthDate   string `json:"birthdate,omitempty"`
	Gender      string `json:"gender,omitempty"`
	Nickname    string `json:"nickname,omitempty"`
	PhoneNumber string `json:"phone_number,omitempty"`
}

IDToken The ID Token represents a JWT passed to the client as part of the token response.

https://openid.net/specs/openid-connect-core-1_0.html#IDToken

type User

type User = auth.User

func UserWithContext added in v0.6.3

func UserWithContext(c *gin.Context) (user *User)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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