Skip to content

Commit

Permalink
fix: remove routers/util (#287)
Browse files Browse the repository at this point in the history
Signed-off-by: sh1luo <690898835@qq.com>
  • Loading branch information
sh1luo committed Sep 5, 2021
1 parent 465d25a commit 9d9a1da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 50 deletions.
3 changes: 2 additions & 1 deletion routers/authz_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func getObject(ctx *context.Context) (string, string) {
if id == "" {
return "", ""
}
return parseSlash(id)
tokens := strings.Split(id, "/")
return tokens[0], tokens[1]
} else {
body := ctx.Input.RequestBody

Expand Down
32 changes: 17 additions & 15 deletions routers/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,33 @@ func getUser(ctx *context.Context) (username string) {
}

func getUserByClientIdSecret(ctx *context.Context) string {
requestUri := ctx.Request.RequestURI
clientId := parseQuery(requestUri, "clientId")
clientSecret := parseQuery(requestUri, "clientSecret")
if len(clientId) == 0 || len(clientSecret) == 0 {
clientId := ctx.Input.Query("clientId")
clientSecret := ctx.Input.Query("clientSecret")
if clientId == "" || clientSecret == "" {
return ""
}

app := object.GetApplicationByClientId(clientId)
if app == nil || app.ClientSecret != clientSecret {
return ""
}

return app.Organization + "/" + app.Name
}

func RecordMessage(ctx *context.Context) {
if ctx.Request.URL.Path != "/api/login" {
user := getUser(ctx)
userinfo := strings.Split(user, "/")
if user == "" {
userinfo = append(userinfo, "")
}
record := util.Records(ctx)
record.Organization = userinfo[0]
record.Username = userinfo[1]

object.AddRecord(record)
if ctx.Request.URL.Path == "/api/login" {
return
}

user := getUser(ctx)
userinfo := strings.Split(user, "/")
if user == "" {
userinfo = append(userinfo, "")
}
record := util.Records(ctx)
record.Organization = userinfo[0]
record.Username = userinfo[1]

object.AddRecord(record)
}
34 changes: 0 additions & 34 deletions routers/util.go

This file was deleted.

0 comments on commit 9d9a1da

Please sign in to comment.