mirror of
https://github.com/go-kratos/kratos.git
synced 2025-11-06 08:59:18 +02:00
@@ -77,7 +77,7 @@ func WithTokenHeader(header map[string]interface{}) Option {
|
||||
func Server(keyFunc jwt.Keyfunc, opts ...Option) middleware.Middleware {
|
||||
o := &options{
|
||||
signingMethod: jwt.SigningMethodHS256,
|
||||
claims: jwt.StandardClaims{},
|
||||
claims: jwt.RegisteredClaims{},
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
@@ -122,7 +122,7 @@ func Server(keyFunc jwt.Keyfunc, opts ...Option) middleware.Middleware {
|
||||
func Client(keyProvider jwt.Keyfunc, opts ...Option) middleware.Middleware {
|
||||
o := &options{
|
||||
signingMethod: jwt.SigningMethodHS256,
|
||||
claims: jwt.StandardClaims{},
|
||||
claims: jwt.RegisteredClaims{},
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
|
||||
@@ -163,7 +163,8 @@ func TestServer(t *testing.T) {
|
||||
|
||||
func TestClient(t *testing.T) {
|
||||
testKey := "testKey"
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{})
|
||||
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.RegisteredClaims{})
|
||||
token, err := claims.SignedString([]byte(testKey))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -209,8 +210,8 @@ func TestClient(t *testing.T) {
|
||||
|
||||
func TestTokenExpire(t *testing.T) {
|
||||
testKey := "testKey"
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
|
||||
ExpiresAt: time.Now().Add(time.Millisecond).Unix(),
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Millisecond)),
|
||||
})
|
||||
token, err := claims.SignedString([]byte(testKey))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user