Skip to content

Commit a48523c

Browse files
committed
update remark
1 parent 78f96db commit a48523c

File tree

9 files changed

+26
-30
lines changed

9 files changed

+26
-30
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
/config.yml
44
/build/
55
/apipark
6-
/aoplatform

init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package main
22

3+
// init module
34
import (
45
_ "github.com/APIParkLab/APIPark/frontend"
56
_ "github.com/APIParkLab/APIPark/gateway/apinto"

initialization-none.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ import (
99
)
1010

1111
func doCheck() {
12-
1312
}

initialization.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import (
66
"bytes"
77
"encoding/csv"
88
"fmt"
9+
"os"
10+
"sort"
11+
"strings"
12+
"time"
13+
914
_ "github.com/APIParkLab/APIPark/resources/access"
1015
_ "github.com/APIParkLab/APIPark/resources/permit"
1116
_ "github.com/APIParkLab/APIPark/resources/plugin"
@@ -14,19 +19,15 @@ import (
1419
"github.com/eolinker/go-common/permit"
1520
"github.com/eolinker/go-common/pm3"
1621
"github.com/eolinker/go-common/utils"
17-
"os"
18-
"sort"
19-
"strings"
20-
"time"
2122
)
2223

2324
const unsetValue = "-"
2425

2526
func doCheck() {
2627
accessConf, unset := loadAccess()
27-
28+
2829
drivers := pm3.List()
29-
30+
3031
newAccess := 0
3132
for _, p := range drivers {
3233
if ac, ok := p.(pm3.AccessConfig); ok {
@@ -39,9 +40,9 @@ func doCheck() {
3940
}
4041
}
4142
}
42-
43+
4344
}
44-
45+
4546
}
4647
for asKey := range permit.All() {
4748
key := strings.ToLower(asKey)
@@ -53,12 +54,11 @@ func doCheck() {
5354
if newAccess > 0 || unset > 0 {
5455
f := accessFile()
5556
fmt.Printf("%d access need set, see : %s and %s", newAccess+unset, saveTemplate(accessConf, f), saveCsv(accessConf, f))
56-
5757
}
5858
os.Exit(0)
5959
}
6060
func accessFile() string {
61-
61+
6262
if version == "" {
6363
return time.Now().Format("20060102-150405")
6464
}
@@ -84,7 +84,7 @@ func saveCsv(as map[string]*Access, key string) string {
8484
err = os.WriteFile(filePath, buf.Bytes(), 0666)
8585
if err != nil {
8686
log.Fatal(err)
87-
87+
8888
}
8989
return filePath
9090
}
@@ -111,9 +111,9 @@ func (ls AccessListSort) Swap(i, j int) {
111111

112112
func saveTemplate(as map[string]*Access, key string) string {
113113
out := make(map[string][]access.Access)
114-
114+
115115
for _, a := range as {
116-
116+
117117
out[a.Group] = append(out[a.Group], access.Access{
118118
Name: a.Name,
119119
CName: a.Cname,
@@ -130,7 +130,7 @@ func saveTemplate(as map[string]*Access, key string) string {
130130
err = os.WriteFile(filePath, buf.Bytes(), 0666)
131131
if err != nil {
132132
log.Fatal(err)
133-
133+
134134
}
135135
return filePath
136136
}

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"net"
7+
"net/http"
8+
69
"github.com/eolinker/eosc/log"
710
"github.com/eolinker/go-common/autowire"
811
"github.com/eolinker/go-common/cftool"
912
"github.com/eolinker/go-common/permit"
1013
"github.com/eolinker/go-common/server"
11-
"net"
12-
"net/http"
1314
)
1415

1516
var (
@@ -54,7 +55,6 @@ func main() {
5455
for access, paths := range srv.Permits() {
5556
permit.AddPermitRule(access, paths...)
5657
}
57-
5858
err = http.Serve(ln, srv)
5959
if err != nil {
6060
log.Fatal(err)

middleware/permit/permit.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package permit_middleware
33
import (
44
"net/http"
55
"reflect"
6-
6+
77
permit_identity "github.com/APIParkLab/APIPark/middleware/permit/identity"
88
"github.com/eolinker/eosc/log"
99
"github.com/eolinker/go-common/autowire"
@@ -42,11 +42,11 @@ func (p *PermitMiddleware) Sort() int {
4242
func (p *PermitMiddleware) Check(method string, path string) (bool, []gin.HandlerFunc) {
4343
// 当前路径是否有配置权限
4444
accessRules, has := permit.GetPathRule(method, path)
45-
45+
4646
if !has || len(accessRules) == 0 {
4747
return false, nil
4848
}
49-
49+
5050
return true, []gin.HandlerFunc{
5151
func(ginCtx *gin.Context) {
5252
userId := utils.UserId(ginCtx)
@@ -56,19 +56,14 @@ func (p *PermitMiddleware) Check(method string, path string) (bool, []gin.Handle
5656
ginCtx.Abort()
5757
return
5858
}
59-
60-
//if userId == "admin" {
61-
// // 超级管理员不校验
62-
// return
63-
//}
64-
59+
6560
for _, group := range checkSort {
6661
accessList, has := accessRules[group]
6762
if !has {
6863
// 当前分组没有配置权限
6964
continue
7065
}
71-
66+
7267
domainHandler, has := permit.SelectDomain(group)
7368
if !has {
7469
// 当前分组没有配置身份handler

model/plugin_model/type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Kind int
99

1010
func (k *Kind) UnmarshalJSON(bytes []byte) error {
1111
str := ""
12+
1213
err := json.Unmarshal(bytes, &str)
1314
if err != nil {
1415
return err

scripts/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 名称:apinto通用镜像
1+
# 名称:apipark通用镜像
22
# 创建时间:2022-10-25
33
FROM centos:7.9.2009
44
MAINTAINER liujian

scripts/prefix.sh

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cd "./eosc" && git pull
2525
# =========================================================================
2626
echo "更新 aoaccount"
2727
cd "${BASEPATH}/"
28+
2829
if [ ! -d "./aoaccount" ]; then
2930
git clone http://gitlab.eolink.com/apinto/aoaccount.git
3031
fi

0 commit comments

Comments
 (0)