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
- Variables
- func AdminAuth(authType string) gin.HandlerFunc
- func AuthCheck(authType string) gin.HandlerFunc
- func GetSignKey() string
- func IsFrozen() gin.HandlerFunc
- func JWTAuth() gin.HandlerFunc
- func SetSignKey(key string) string
- func VerifyKeyWord() gin.HandlerFunc
- func VerifyParamSignMiddleWare() gin.HandlerFunc
- type CustomClaims
- type JWT
- type ReqBody
Constants ¶
const ReqTimeOut = 20 * 1000
const TOKEN_EXP = 24 // token有效周期
Variables ¶
Functions ¶
func AdminAuth ¶
func AdminAuth(authType string) gin.HandlerFunc
AdminAuth middleware to validate userType, owner: "owner", admin:"admin"
func GetSignKey ¶
func GetSignKey() string
func JWTAuth ¶
func JWTAuth() gin.HandlerFunc
func SetSignKey ¶
func VerifyParamSignMiddleWare ¶
func VerifyParamSignMiddleWare() gin.HandlerFunc
Types ¶
type CustomClaims ¶
type JWT ¶
type JWT struct {
SigningKey []byte
}
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)