Support server-side upload-resource call.

This commit is contained in:
Yang Luo
2021-09-05 01:03:29 +08:00
parent 06006c87b8
commit 14d09cad2c
6 changed files with 58 additions and 25 deletions

View File

@ -14,7 +14,12 @@
package routers
import "github.com/astaxie/beego/context"
import (
"fmt"
"github.com/astaxie/beego/context"
"github.com/casbin/casdoor/object"
)
type Response struct {
Status string `json:"status"`
@ -42,3 +47,18 @@ func responseError(ctx *context.Context, error string, data ...interface{}) {
func denyRequest(ctx *context.Context) {
responseError(ctx, "Unauthorized operation")
}
func getUsernameByClientIdSecret(ctx *context.Context) string {
clientId := ctx.Input.Query("clientId")
clientSecret := ctx.Input.Query("clientSecret")
if clientId == "" || clientSecret == "" {
return ""
}
application := object.GetApplicationByClientId(clientId)
if application == nil || application.ClientSecret != clientSecret {
return ""
}
return fmt.Sprintf("app/%s", application.Name)
}