Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 9d42a0f

Browse files
authored
Merge pull request #1 from gogf/qiangg_jwt
update some details
2 parents a40ac14 + 0d56941 commit 9d42a0f

File tree

7 files changed

+27
-38
lines changed

7 files changed

+27
-38
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# gf-jwt
2-
Gf jwt plugin
2+
GF jwt plugin
33

4-
This plugin is forked [https://github.com/appleboy/gin-jwt](https://github.com/appleboy/gin-jwt) plugin, modified to [https://github.com/gogf/ Gf](https://github.com/gogf/gf) plugin.
4+
This plugin is forked [https://github.com/appleboy/gin-jwt](https://github.com/appleboy/gin-jwt) plugin, modified to [https://github.com/gogf/gf](https://github.com/gogf/gf) plugin.
55

66

77
[英文](README.md) [中文](README_zh.md)
@@ -12,13 +12,13 @@ This plugin is forked [https://github.com/appleboy/gin-jwt](https://github.com/a
1212
Download and install
1313

1414
```sh
15-
$ go get github.com/zhaopengme/gf-jwt
15+
$ go get github.com/gogf/gf-jwt
1616
```
1717

1818
Import
1919

2020
```go
21-
Import "github.com/zhaopengme/gf-jwt"
21+
import "github.com/gogf/gf-jwt"
2222
```
2323

2424
## example
@@ -34,7 +34,7 @@ import (
3434
"github.com/gogf/gf/g"
3535
"github.com/gogf/gf/g/net/ghttp"
3636
"github.com/gogf/gf/g/util/gvalid"
37-
"github.com/zhaopengme/gf-jwt"
37+
"github.com/gogf/gf-jwt"
3838
"log"
3939
"net/http"
4040
"time"

README_zh.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gf-jwt
2-
gf 的 jwt 插件
2+
gf 的 jwt 插件
33

44
这个插件是 fork 了 [https://github.com/appleboy/gin-jwt](https://github.com/appleboy/gin-jwt) 插件,修改为 [https://github.com/gogf/gf](https://github.com/gogf/gf) 插件.
55

@@ -12,13 +12,13 @@ gf 的 jwt 插件
1212
下载安装
1313

1414
```sh
15-
$ go get github.com/zhaopengme/gf-jwt
15+
$ go get github.com/gogf/gf-jwt
1616
```
1717

1818
导入
1919

2020
```go
21-
import "github.com/zhaopengme/gf-jwt"
21+
import "github.com/gogf/gf-jwt"
2222
```
2323

2424
## 例子
@@ -34,7 +34,7 @@ import (
3434
"github.com/gogf/gf/g"
3535
"github.com/gogf/gf/g/net/ghttp"
3636
"github.com/gogf/gf/g/util/gvalid"
37-
"github.com/zhaopengme/gf-jwt"
37+
"github.com/gogf/gf-jwt"
3838
"log"
3939
"net/http"
4040
"time"
@@ -187,4 +187,4 @@ $ http -f GET localhost:8000/user/hello "Authorization:Bearer xxxxxxxxx" "Conte
187187
![api screenshot](screenshot/401.png)
188188

189189

190-
再次感谢[https://github.com/appleboy/gin-jwt](https://github.com/appleboy/gin-jwt)
190+
再次感谢[https://github.com/appleboy/gin-jwt](https://github.com/appleboy/gin-jwt)

auth_jwt.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package jwt
22

33
import (
4-
"crypto/rsa"
5-
"errors"
6-
"github.com/gogf/gf/g"
7-
"github.com/gogf/gf/g/net/ghttp"
8-
"io/ioutil"
9-
"net/http"
10-
"strings"
11-
"time"
12-
13-
"github.com/dgrijalva/jwt-go"
4+
"crypto/rsa"
5+
"errors"
6+
"github.com/gogf/gf/g"
7+
"github.com/gogf/gf/g/net/ghttp"
8+
"io/ioutil"
9+
"net/http"
10+
"strings"
11+
"time"
1412
)
1513

1614
// MapClaims type that uses the map[string]interface{} for JSON decoding
@@ -322,7 +320,7 @@ func (mw *GfJWTMiddleware) MiddlewareInit() error {
322320
}
323321

324322
if mw.Realm == "" {
325-
mw.Realm = "gin jwt"
323+
mw.Realm = "gf jwt"
326324
}
327325

328326
if mw.CookieName == "" {

example/auth/index.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package auth
22

33
import (
4+
"github.com/gogf/gf-jwt"
45
"github.com/gogf/gf/g"
56
"github.com/gogf/gf/g/net/ghttp"
67
"github.com/gogf/gf/g/util/gvalid"
7-
"github.com/zhaopengme/gf-jwt"
88
"log"
99
"net/http"
1010
"time"
@@ -89,8 +89,8 @@ func (d *Default) Authenticator(r *ghttp.Request) (interface{}, error) {
8989
if e := gvalid.CheckMap(data, d.Rules); e != nil {
9090
return "", jwt.ErrFailedAuthentication
9191
}
92-
if (data["username"] == "admin" && data["password"] == "admin") {
93-
return g.Map{
92+
if data["username"] == "admin" && data["password"] == "admin" {
93+
return g.Map {
9494
"username": data["username"],
9595
"id": data["username"],
9696
}, nil

example/server/index.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package main
22

33
import (
4+
"github.com/gogf/gf-jwt/example/auth"
45
"github.com/gogf/gf/g"
56
"github.com/gogf/gf/g/net/ghttp"
6-
"github.com/zhaopengme/gf-jwt/example/auth"
77
)
88

99
func hello(r *ghttp.Request) {
10-
r.Response.Write("哈喽世界!")
10+
r.Response.Write("Hello World!")
1111
}
1212

1313
func main() {
@@ -27,7 +27,7 @@ func main() {
2727
})
2828

2929
s.BindHandler("/", func(r *ghttp.Request) {
30-
r.Response.Write("it's work!")
30+
r.Response.Write("It works!")
3131
})
3232
s.SetPort(8000)
3333
s.Run()

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module github.com/zhaopengme/gf-jwt
1+
module github.com/gogf/gf-jwt
22

33
require (
4+
github.com/gogf/gf v1.5.16
45
github.com/dgrijalva/jwt-go v3.2.0+incompatible
5-
github.com/gogf/gf v1.5.15
66
google.golang.org/appengine v1.4.0 // indirect
77
)

go.sum

-9
This file was deleted.

0 commit comments

Comments
 (0)