Auth: Move Team service to SignedInUserInterface (#72674)
* move SignedInUser to specific file * add primitive interface for signedInUser
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
)
|
||||
|
||||
var sqlIDAcceptList = map[string]struct{}{
|
||||
@@ -33,18 +33,19 @@ type SQLFilter struct {
|
||||
// Filter creates a where clause to restrict the view of a query based on a users permissions
|
||||
// Scopes that exists for all actions will be parsed and compared against the supplied sqlID
|
||||
// Prefix parameter is the prefix of the scope that we support (e.g. "users:id:")
|
||||
func Filter(user *user.SignedInUser, sqlID, prefix string, actions ...string) (SQLFilter, error) {
|
||||
func Filter(user identity.Requester, sqlID, prefix string, actions ...string) (SQLFilter, error) {
|
||||
if _, ok := sqlIDAcceptList[sqlID]; !ok {
|
||||
return denyQuery, errors.New("sqlID is not in the accept list")
|
||||
}
|
||||
if user == nil || user.Permissions == nil || user.Permissions[user.OrgID] == nil {
|
||||
|
||||
if user == nil || user.IsNil() {
|
||||
return denyQuery, errors.New("missing permissions")
|
||||
}
|
||||
|
||||
wildcards := 0
|
||||
result := make(map[interface{}]int)
|
||||
for _, a := range actions {
|
||||
ids, hasWildcard := ParseScopes(prefix, user.Permissions[user.OrgID][a])
|
||||
ids, hasWildcard := ParseScopes(prefix, user.GetPermissions(user.GetOrgID())[a])
|
||||
if hasWildcard {
|
||||
wildcards += 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user