Compare commits

...

2 Commits

Author SHA1 Message Date
ccb4045065 update go mod 2023-08-10 17:33:04 +08:00
ddd2413386 remove jwt 2023-08-10 17:32:31 +08:00
4 changed files with 0 additions and 77 deletions

2
go.mod
View File

@ -6,11 +6,9 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/Jeffail/gabs v1.4.0
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1
github.com/go-ini/ini v1.67.0
github.com/mitchellh/go-homedir v1.1.0
github.com/mozillazg/go-pinyin v0.20.0
github.com/mssola/user_agent v0.6.0
github.com/pkg/errors v0.9.1
github.com/spaolacci/murmur3 v1.1.0
github.com/stretchr/testify v1.8.2

6
go.sum
View File

@ -7,16 +7,12 @@ github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIg
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 h1:CaO/zOnF8VvUfEbhRatPcwKVWamvbYd8tQGRWacE9kU=
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1/go.mod h1:+hnT3ywWDTAFrW5aE+u2Sa/wT555ZqwoCS+pk3p6ry4=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ=
github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
github.com/mssola/user_agent v0.6.0 h1:uwPR4rtWlCHRFyyP9u2KOV0u8iQXmS7Z7feTrstQwk4=
github.com/mssola/user_agent v0.6.0/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -37,8 +33,6 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -24,8 +24,6 @@ var (
Project *project
// Array 数组操作
Array *array
// JWT ...
JWT *ownJwt
// Console 控制台输出数据
Console *console
// PinYin 汉字转拼音
@ -41,7 +39,6 @@ func init() {
Calculate = &calculate{}
Project = &project{}
Array = &array{}
JWT = &ownJwt{}
Console = &console{}
PinYin = &pinYin{}
}

66
jwt.go
View File

@ -1,66 +0,0 @@
// Package util ...
//
// Description : go-jwt具体实现
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2023-02-11 20:09
package util
import (
"errors"
"github.com/dgrijalva/jwt-go/v4"
)
type ownJwt struct {
}
type MyClaims struct {
jwt.StandardClaims
}
// Generate 生成 token
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:13 2023/2/11
func (j *ownJwt) Generate(signMethod jwt.SigningMethod, secret string, claims jwt.Claims) (string, error) {
if nil == signMethod {
signMethod = jwt.SigningMethodHS256
}
var (
token *jwt.Token
)
if nil == claims {
token = jwt.New(signMethod)
} else {
token = jwt.NewWithClaims(signMethod, claims)
}
return token.SignedString([]byte(secret))
}
// Validate 验证token
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:13 2023/2/11
func (j *ownJwt) Validate(inputToken string, secret string, claims jwt.Claims) (jwt.Claims, error) {
var (
token *jwt.Token
err error
)
if token, err = jwt.ParseWithClaims(inputToken, claims, func(tokenInfo *jwt.Token) (interface{}, error) {
return []byte(secret), nil
}); nil != err {
return nil, errors.New("token parse fail : " + err.Error())
}
if !token.Valid {
return nil, errors.New("token is valid : " + err.Error())
}
return token.Claims, nil
}