update checkAuthority
This commit is contained in:
parent
5864585b61
commit
e7296d2b5e
@ -5,6 +5,8 @@ go 1.19
|
||||
require (
|
||||
github.com/coreos/go-oidc v2.2.1+incompatible
|
||||
github.com/gin-gonic/gin v1.8.2
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3
|
||||
github.com/google/uuid v1.3.0
|
||||
golang.org/x/oauth2 v0.3.0
|
||||
)
|
||||
|
||||
|
@ -18,6 +18,8 @@ github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJ
|
||||
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
|
||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
@ -25,6 +27,8 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
@ -95,7 +95,7 @@ func authCallback(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ss, err := authmod.IssueJWT(userInfo, time.Second)
|
||||
ss, err := authmod.IssueJWT(userInfo, time.Hour)
|
||||
if err != nil {
|
||||
http.Error(ctx.Writer, "generate jwt error", http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -29,7 +29,7 @@ func NewRouter() *gin.Engine {
|
||||
r.Any("/*any", func(c *gin.Context) {
|
||||
defer handleError(c)
|
||||
path := c.Param("any")
|
||||
if strings.HasPrefix(path, "/dashboard") {
|
||||
if strings.HasPrefix(path, "/home") {
|
||||
assetEngine.HandleContext(c)
|
||||
return
|
||||
} else if strings.HasPrefix(path, "/auth") {
|
||||
@ -71,14 +71,9 @@ func checkAuthority(c *gin.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
claims, err := authmod.ParseJWTwithClaims(editAuth)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, err = authmod.ParseJWTwithClaims(editAuth)
|
||||
|
||||
fmt.Println(claims.UserInfo)
|
||||
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func handleError(c *gin.Context) {
|
||||
|
Loading…
Reference in New Issue
Block a user