middleware

package
v0.0.0-...-7cf6ef0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const ReqTimeOut = 20 * 1000
View Source
const TOKEN_EXP = 24 // token有效周期

Variables

View Source
var (
	TokenExpired     error  = errors.New("Token is expired")
	TokenNotValidYet error  = errors.New("Token not active yet")
	TokenMalformed   error  = errors.New("That's not even a token")
	TokenInvalid     error  = errors.New("Couldn't handle this token:")
	SignKey          string = "box.la"
)

Functions

func AdminAuth

func AdminAuth(authType string) gin.HandlerFunc

AdminAuth middleware to validate userType, owner: "owner", admin:"admin"

func AuthCheck

func AuthCheck(authType string) gin.HandlerFunc

AuthCheck 权限校验

func GetSignKey

func GetSignKey() string

func IsFrozen

func IsFrozen() gin.HandlerFunc

IsFrozen check account is frozen

func JWTAuth

func JWTAuth() gin.HandlerFunc

func SetSignKey

func SetSignKey(key string) string

func VerifyKeyWord

func VerifyKeyWord() gin.HandlerFunc

VerifyKeyWord validate key word

func VerifyParamSignMiddleWare

func VerifyParamSignMiddleWare() gin.HandlerFunc

Types

type CustomClaims

type CustomClaims struct {
	ID       int
	AppID    string `json:"appid"`
	Account  string `json:"account"`
	UserType int    `json:"userType"`
	PubKey   string
	Level    int
	jwt.StandardClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims CustomClaims) (string, error)

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)

type ReqBody

type ReqBody struct {
	AppID     string `form:"app_id"`
	AppName   string `form:"name"`
	AesKey    string `form:"aeskey"`
	Msg       string `form:"msg"`
	Sign      string `form:"sign"`
	Timestamp int64  `form:"timestamp"`
}

Jump to

Keyboard shortcuts

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