Documentation
¶
Index ¶
- Constants
- Variables
- func AuthUserMiddleware(redirect bool) gin.HandlerFunc
- func AvatarHTML(s string) template.HTML
- func ContextWithSiteFromRequest(req *http.Request) context.Context
- func DeleteTGC(c *gin.Context)
- func GetTGC(c *gin.Context) *cas.Ticket
- func IsAjax(r *http.Request) bool
- func LoadPrivateKey(data []byte) (interface{}, error)
- func New(c Config) *server
- func NewTGC(c *gin.Context, ticket *cas.Ticket)
- func RequestScheme(r *http.Request) string
- func SessionLoad(r *http.Request) session.Session
- func SessionSave(sess session.Session, w http.ResponseWriter)
- func SetBase(s string)
- func UrlFor(path string) string
- func UserFromStaff(staff *models.Staff) *auth.User
- type AccessTokenGenJWT
- type Config
- type IDToken
- type MapGetter
- type TokenGenerator
- type User
Constants ¶
View Source
const ( LimitArticle = 3 LimitLinks = 20 )
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
AvatarHTML 生成头像的HTML标签,目前仅支持微信头像
func ContextWithSiteFromRequest ¶ added in v0.12.6
func LoadPrivateKey ¶ added in v0.12.4
LoadPrivateKey loads a private key from PEM/DER data.
func RequestScheme ¶ added in v0.12.4
func SessionSave ¶ added in v0.8.1
func SessionSave(sess session.Session, w http.ResponseWriter)
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)
func (*AccessTokenGenJWT) GenerateIDToken ¶ added in v0.12.6
func (c *AccessTokenGenJWT) GenerateIDToken(mg MapGetter) (string, error)
type IDToken ¶ added in v0.12.3
type IDToken struct {
Issuer string `json:"iss"` // REQUIRED. Issuer Identifier for the Issuer of the response.
UserID string `json:"sub"` // REQUIRED. Subject Identifier.
ClientID string `json:"aud"` // REQUIRED. Audience(s) that this ID Token is intended for.
Expiration int64 `json:"exp"` // REQUIRED. Expiration time on or after which the ID Token
IssuedAt int64 `json:"iat"` // REQUIRED. Time at which the JWT was issued.
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"`
Picture string `json:"picture,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 TokenGenerator ¶ added in v0.12.6
type TokenGenerator interface {
osin.AccessTokenGen
GenerateIDToken(mg MapGetter) (string, error)
// contains filtered or unexported methods
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.