Skip to content

Commit

Permalink
Add DomainRole model
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Jul 27, 2024
1 parent 6f52428 commit 8818c9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/user/user_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/alexedwards/argon2id"
"github.com/oj-lab/oj-lab-platform/models"
casbin_agent "github.com/oj-lab/oj-lab-platform/modules/agent/casbin"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
Expand Down Expand Up @@ -86,6 +87,7 @@ func UpdateUser(tx *gorm.DB, update User) error {
type GetUserOptions struct {
AccountQuery string
EmailQuery string
DomainRole *casbin_agent.DomainRole
Offset *int
Limit *int
}
Expand Down
8 changes: 8 additions & 0 deletions modules/agent/casbin/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
m = g(r.sub, p.sub) && eval(p.ext_rule) && r.dom == p.dom && keyMatchGin(r.obj, p.obj) && regexMatch(r.act, p.act)
`

const UserSubjectPrefix = "user_"
const RoleSubjectPrefix = "role_"

type ExtraInfo struct {
IsVIP bool
}

type DomainRole struct {
Role string
Domain string
}

0 comments on commit 8818c9e

Please sign in to comment.