2022-01-14 09:45:50 +00:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
errs "errors"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
sq "github.com/Masterminds/squirrel"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
2022-08-31 07:52:43 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/errors"
|
|
|
|
"github.com/zitadel/zitadel/internal/query/projection"
|
2022-01-14 09:45:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserGrant struct {
|
|
|
|
ID string
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
2022-08-31 07:52:43 +00:00
|
|
|
Roles database.StringArray
|
2022-01-14 09:45:50 +00:00
|
|
|
GrantID string
|
|
|
|
State domain.UserGrantState
|
|
|
|
|
2022-03-24 13:00:24 +00:00
|
|
|
UserID string
|
|
|
|
Username string
|
|
|
|
UserType domain.UserType
|
|
|
|
UserResourceOwner string
|
|
|
|
FirstName string
|
|
|
|
LastName string
|
|
|
|
Email string
|
|
|
|
DisplayName string
|
|
|
|
AvatarURL string
|
|
|
|
PreferredLoginName string
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
ResourceOwner string
|
|
|
|
OrgName string
|
|
|
|
OrgPrimaryDomain string
|
|
|
|
|
|
|
|
ProjectID string
|
|
|
|
ProjectName string
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserGrants struct {
|
|
|
|
SearchResponse
|
|
|
|
UserGrants []*UserGrant
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserGrantsQueries struct {
|
|
|
|
SearchRequest
|
|
|
|
Queries []SearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *UserGrantsQueries) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
|
|
|
|
query = q.SearchRequest.toQuery(query)
|
|
|
|
for _, q := range q.Queries {
|
|
|
|
query = q.toQuery(query)
|
|
|
|
}
|
|
|
|
return query
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantUserIDSearchQuery(id string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserGrantUserID, id, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantProjectIDSearchQuery(id string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserGrantProjectID, id, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantProjectOwnerSearchQuery(id string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(ProjectColumnResourceOwner, id, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantResourceOwnerSearchQuery(id string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserGrantResourceOwner, id, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantGrantIDSearchQuery(id string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserGrantGrantID, id, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantUserTypeQuery(typ domain.UserType) (SearchQuery, error) {
|
|
|
|
return NewNumberQuery(UserTypeCol, typ, NumberEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantDisplayNameQuery(displayName string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanDisplayNameCol, displayName, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantEmailQuery(email string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanEmailCol, email, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantFirstNameQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanFirstNameCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantLastNameQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanLastNameCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantUsernameQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserUsernameCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantDomainQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(OrgColumnDomain, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantOrgNameQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(OrgColumnName, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantProjectNameQuery(value string, method TextComparison) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(ProjectColumnName, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantRoleQuery(value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(UserGrantRoles, value, TextListContains)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantWithGrantedQuery(owner string) (SearchQuery, error) {
|
|
|
|
orgQuery, err := NewUserGrantResourceOwnerSearchQuery(owner)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
projectQuery, err := NewUserGrantProjectOwnerSearchQuery(owner)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return newOrQuery(orgQuery, projectQuery)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserGrantContainsRolesSearchQuery(roles ...string) (SearchQuery, error) {
|
|
|
|
r := make([]interface{}, len(roles))
|
|
|
|
for i, role := range roles {
|
|
|
|
r[i] = role
|
|
|
|
}
|
|
|
|
return NewListQuery(UserGrantRoles, r, ListIn)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
userGrantTable = table{
|
2022-10-27 06:08:36 +00:00
|
|
|
name: projection.UserGrantProjectionTable,
|
|
|
|
instanceIDCol: projection.UserGrantInstanceID,
|
2022-01-14 09:45:50 +00:00
|
|
|
}
|
|
|
|
UserGrantID = Column{
|
|
|
|
name: projection.UserGrantID,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantResourceOwner = Column{
|
|
|
|
name: projection.UserGrantResourceOwner,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
2022-03-23 08:02:39 +00:00
|
|
|
UserGrantInstanceID = Column{
|
|
|
|
name: projection.UserGrantInstanceID,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
2022-01-14 09:45:50 +00:00
|
|
|
UserGrantCreationDate = Column{
|
|
|
|
name: projection.UserGrantCreationDate,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantChangeDate = Column{
|
|
|
|
name: projection.UserGrantChangeDate,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantSequence = Column{
|
|
|
|
name: projection.UserGrantSequence,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantUserID = Column{
|
|
|
|
name: projection.UserGrantUserID,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantProjectID = Column{
|
|
|
|
name: projection.UserGrantProjectID,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantGrantID = Column{
|
|
|
|
name: projection.UserGrantGrantID,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantRoles = Column{
|
|
|
|
name: projection.UserGrantRoles,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantState = Column{
|
|
|
|
name: projection.UserGrantState,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
2022-11-30 16:01:17 +00:00
|
|
|
UserGrantOwnerRemoved = Column{
|
|
|
|
name: projection.UserGrantOwnerRemoved,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantUserOwnerRemoved = Column{
|
|
|
|
name: projection.UserGrantUserOwnerRemoved,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantProjectOwnerRemoved = Column{
|
|
|
|
name: projection.UserGrantProjectOwnerRemoved,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
|
|
|
UserGrantGrantGrantedOrgRemoved = Column{
|
|
|
|
name: projection.UserGrantGrantedOrgRemoved,
|
|
|
|
table: userGrantTable,
|
|
|
|
}
|
2022-01-14 09:45:50 +00:00
|
|
|
)
|
|
|
|
|
2022-11-30 16:01:17 +00:00
|
|
|
func addUserGrantWithoutOwnerRemoved(eq map[string]interface{}) {
|
|
|
|
eq[UserGrantOwnerRemoved.identifier()] = false
|
|
|
|
eq[UserGrantUserOwnerRemoved.identifier()] = false
|
|
|
|
eq[UserGrantProjectOwnerRemoved.identifier()] = false
|
|
|
|
eq[UserGrantGrantGrantedOrgRemoved.identifier()] = false
|
|
|
|
addLoginNameWithoutOwnerRemoved(eq)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) UserGrant(ctx context.Context, shouldTriggerBulk bool, withOwnerRemoved bool, queries ...SearchQuery) (*UserGrant, error) {
|
2022-06-14 05:51:00 +00:00
|
|
|
if shouldTriggerBulk {
|
2022-07-22 10:08:39 +00:00
|
|
|
projection.UserGrantProjection.Trigger(ctx)
|
2022-06-14 05:51:00 +00:00
|
|
|
}
|
|
|
|
|
2022-01-14 09:45:50 +00:00
|
|
|
query, scan := prepareUserGrantQuery()
|
|
|
|
for _, q := range queries {
|
|
|
|
query = q.toQuery(query)
|
|
|
|
}
|
2022-11-30 16:01:17 +00:00
|
|
|
eq := sq.Eq{UserGrantInstanceID.identifier(): authz.GetInstance(ctx).InstanceID()}
|
|
|
|
if !withOwnerRemoved {
|
|
|
|
addUserGrantWithoutOwnerRemoved(eq)
|
|
|
|
}
|
|
|
|
stmt, args, err := query.Where(eq).ToSql()
|
2022-01-14 09:45:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "QUERY-Fa1KW", "Errors.Query.SQLStatement")
|
|
|
|
}
|
|
|
|
|
|
|
|
row := q.client.QueryRowContext(ctx, stmt, args...)
|
|
|
|
return scan(row)
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:01:17 +00:00
|
|
|
func (q *Queries) UserGrants(ctx context.Context, queries *UserGrantsQueries, withOwnerRemoved bool) (*UserGrants, error) {
|
2022-01-14 09:45:50 +00:00
|
|
|
query, scan := prepareUserGrantsQuery()
|
2022-11-30 16:01:17 +00:00
|
|
|
eq := sq.Eq{UserGrantInstanceID.identifier(): authz.GetInstance(ctx).InstanceID()}
|
|
|
|
if !withOwnerRemoved {
|
|
|
|
addUserGrantWithoutOwnerRemoved(eq)
|
|
|
|
}
|
|
|
|
stmt, args, err := queries.toQuery(query).Where(eq).ToSql()
|
2022-01-14 09:45:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "QUERY-wXnQR", "Errors.Query.SQLStatement")
|
|
|
|
}
|
|
|
|
|
|
|
|
latestSequence, err := q.latestSequence(ctx, userGrantTable)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
rows, err := q.client.QueryContext(ctx, stmt, args...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
grants, err := scan(rows)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
grants.LatestSequence = latestSequence
|
|
|
|
return grants, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func prepareUserGrantQuery() (sq.SelectBuilder, func(*sql.Row) (*UserGrant, error)) {
|
|
|
|
return sq.Select(
|
|
|
|
UserGrantID.identifier(),
|
|
|
|
UserGrantCreationDate.identifier(),
|
|
|
|
UserGrantChangeDate.identifier(),
|
|
|
|
UserGrantSequence.identifier(),
|
|
|
|
UserGrantGrantID.identifier(),
|
|
|
|
UserGrantRoles.identifier(),
|
|
|
|
UserGrantState.identifier(),
|
|
|
|
|
|
|
|
UserGrantUserID.identifier(),
|
|
|
|
UserUsernameCol.identifier(),
|
|
|
|
UserTypeCol.identifier(),
|
|
|
|
UserResourceOwnerCol.identifier(),
|
|
|
|
HumanFirstNameCol.identifier(),
|
|
|
|
HumanLastNameCol.identifier(),
|
|
|
|
HumanEmailCol.identifier(),
|
|
|
|
HumanDisplayNameCol.identifier(),
|
2022-01-20 14:40:25 +00:00
|
|
|
HumanAvatarURLCol.identifier(),
|
2022-03-24 13:00:24 +00:00
|
|
|
LoginNameNameCol.identifier(),
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
UserGrantResourceOwner.identifier(),
|
|
|
|
OrgColumnName.identifier(),
|
|
|
|
OrgColumnDomain.identifier(),
|
|
|
|
|
|
|
|
UserGrantProjectID.identifier(),
|
|
|
|
ProjectColumnName.identifier(),
|
|
|
|
).
|
|
|
|
From(userGrantTable.identifier()).
|
|
|
|
LeftJoin(join(UserIDCol, UserGrantUserID)).
|
|
|
|
LeftJoin(join(HumanUserIDCol, UserGrantUserID)).
|
|
|
|
LeftJoin(join(OrgColumnID, UserGrantResourceOwner)).
|
|
|
|
LeftJoin(join(ProjectColumnID, UserGrantProjectID)).
|
2022-03-24 13:00:24 +00:00
|
|
|
LeftJoin(join(LoginNameUserIDCol, UserGrantUserID)).
|
|
|
|
Where(
|
|
|
|
sq.Eq{LoginNameIsPrimaryCol.identifier(): true},
|
|
|
|
).PlaceholderFormat(sq.Dollar),
|
2022-01-14 09:45:50 +00:00
|
|
|
func(row *sql.Row) (*UserGrant, error) {
|
|
|
|
g := new(UserGrant)
|
|
|
|
|
|
|
|
var (
|
2022-03-24 13:00:24 +00:00
|
|
|
username sql.NullString
|
|
|
|
firstName sql.NullString
|
|
|
|
userType sql.NullInt32
|
|
|
|
userOwner sql.NullString
|
|
|
|
lastName sql.NullString
|
|
|
|
email sql.NullString
|
|
|
|
displayName sql.NullString
|
|
|
|
avatarURL sql.NullString
|
|
|
|
preferredLoginName sql.NullString
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
orgName sql.NullString
|
|
|
|
orgDomain sql.NullString
|
|
|
|
|
|
|
|
projectName sql.NullString
|
|
|
|
)
|
|
|
|
|
|
|
|
err := row.Scan(
|
|
|
|
&g.ID,
|
|
|
|
&g.CreationDate,
|
|
|
|
&g.ChangeDate,
|
|
|
|
&g.Sequence,
|
|
|
|
&g.GrantID,
|
2022-08-31 07:52:43 +00:00
|
|
|
&g.Roles,
|
2022-01-14 09:45:50 +00:00
|
|
|
&g.State,
|
|
|
|
|
|
|
|
&g.UserID,
|
|
|
|
&username,
|
|
|
|
&userType,
|
|
|
|
&userOwner,
|
|
|
|
&firstName,
|
|
|
|
&lastName,
|
|
|
|
&email,
|
|
|
|
&displayName,
|
|
|
|
&avatarURL,
|
2022-03-24 13:00:24 +00:00
|
|
|
&preferredLoginName,
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
&g.ResourceOwner,
|
|
|
|
&orgName,
|
|
|
|
&orgDomain,
|
|
|
|
|
|
|
|
&g.ProjectID,
|
|
|
|
&projectName,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if errs.Is(err, sql.ErrNoRows) {
|
|
|
|
return nil, errors.ThrowNotFound(err, "QUERY-wIPkA", "Errors.UserGrant.NotFound")
|
|
|
|
}
|
|
|
|
return nil, errors.ThrowInternal(err, "QUERY-oQPcP", "Errors.Internal")
|
|
|
|
}
|
|
|
|
|
|
|
|
g.Username = username.String
|
|
|
|
g.UserType = domain.UserType(userType.Int32)
|
|
|
|
g.UserResourceOwner = userOwner.String
|
|
|
|
g.FirstName = firstName.String
|
|
|
|
g.LastName = lastName.String
|
|
|
|
g.Email = email.String
|
|
|
|
g.DisplayName = displayName.String
|
|
|
|
g.AvatarURL = avatarURL.String
|
2022-03-24 13:00:24 +00:00
|
|
|
g.PreferredLoginName = preferredLoginName.String
|
2022-01-14 09:45:50 +00:00
|
|
|
g.OrgName = orgName.String
|
|
|
|
g.OrgPrimaryDomain = orgDomain.String
|
|
|
|
g.ProjectName = projectName.String
|
|
|
|
|
|
|
|
return g, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func prepareUserGrantsQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserGrants, error)) {
|
|
|
|
return sq.Select(
|
|
|
|
UserGrantID.identifier(),
|
|
|
|
UserGrantCreationDate.identifier(),
|
|
|
|
UserGrantChangeDate.identifier(),
|
|
|
|
UserGrantSequence.identifier(),
|
|
|
|
UserGrantGrantID.identifier(),
|
|
|
|
UserGrantRoles.identifier(),
|
|
|
|
UserGrantState.identifier(),
|
|
|
|
|
|
|
|
UserGrantUserID.identifier(),
|
|
|
|
UserUsernameCol.identifier(),
|
|
|
|
UserTypeCol.identifier(),
|
|
|
|
UserResourceOwnerCol.identifier(),
|
|
|
|
HumanFirstNameCol.identifier(),
|
|
|
|
HumanLastNameCol.identifier(),
|
|
|
|
HumanEmailCol.identifier(),
|
|
|
|
HumanDisplayNameCol.identifier(),
|
2022-01-20 14:40:25 +00:00
|
|
|
HumanAvatarURLCol.identifier(),
|
2022-03-24 13:00:24 +00:00
|
|
|
LoginNameNameCol.identifier(),
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
UserGrantResourceOwner.identifier(),
|
|
|
|
OrgColumnName.identifier(),
|
|
|
|
OrgColumnDomain.identifier(),
|
|
|
|
|
|
|
|
UserGrantProjectID.identifier(),
|
|
|
|
ProjectColumnName.identifier(),
|
|
|
|
|
|
|
|
countColumn.identifier(),
|
|
|
|
).
|
|
|
|
From(userGrantTable.identifier()).
|
|
|
|
LeftJoin(join(UserIDCol, UserGrantUserID)).
|
|
|
|
LeftJoin(join(HumanUserIDCol, UserGrantUserID)).
|
|
|
|
LeftJoin(join(OrgColumnID, UserGrantResourceOwner)).
|
|
|
|
LeftJoin(join(ProjectColumnID, UserGrantProjectID)).
|
2022-03-24 13:00:24 +00:00
|
|
|
LeftJoin(join(LoginNameUserIDCol, UserGrantUserID)).
|
|
|
|
Where(
|
|
|
|
sq.Eq{LoginNameIsPrimaryCol.identifier(): true},
|
|
|
|
).PlaceholderFormat(sq.Dollar),
|
2022-01-14 09:45:50 +00:00
|
|
|
func(rows *sql.Rows) (*UserGrants, error) {
|
|
|
|
userGrants := make([]*UserGrant, 0)
|
|
|
|
var count uint64
|
|
|
|
for rows.Next() {
|
|
|
|
g := new(UserGrant)
|
|
|
|
|
|
|
|
var (
|
2022-03-24 13:00:24 +00:00
|
|
|
username sql.NullString
|
|
|
|
userType sql.NullInt32
|
|
|
|
userOwner sql.NullString
|
|
|
|
firstName sql.NullString
|
|
|
|
lastName sql.NullString
|
|
|
|
email sql.NullString
|
|
|
|
displayName sql.NullString
|
|
|
|
avatarURL sql.NullString
|
|
|
|
preferredLoginName sql.NullString
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
orgName sql.NullString
|
|
|
|
orgDomain sql.NullString
|
|
|
|
|
|
|
|
projectName sql.NullString
|
|
|
|
)
|
|
|
|
|
|
|
|
err := rows.Scan(
|
|
|
|
&g.ID,
|
|
|
|
&g.CreationDate,
|
|
|
|
&g.ChangeDate,
|
|
|
|
&g.Sequence,
|
|
|
|
&g.GrantID,
|
2022-08-31 07:52:43 +00:00
|
|
|
&g.Roles,
|
2022-01-14 09:45:50 +00:00
|
|
|
&g.State,
|
|
|
|
|
|
|
|
&g.UserID,
|
|
|
|
&username,
|
|
|
|
&userType,
|
|
|
|
&userOwner,
|
|
|
|
&firstName,
|
|
|
|
&lastName,
|
|
|
|
&email,
|
|
|
|
&displayName,
|
|
|
|
&avatarURL,
|
2022-03-24 13:00:24 +00:00
|
|
|
&preferredLoginName,
|
2022-01-14 09:45:50 +00:00
|
|
|
|
|
|
|
&g.ResourceOwner,
|
|
|
|
&orgName,
|
|
|
|
&orgDomain,
|
|
|
|
|
|
|
|
&g.ProjectID,
|
|
|
|
&projectName,
|
|
|
|
|
|
|
|
&count,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
g.Username = username.String
|
|
|
|
g.UserType = domain.UserType(userType.Int32)
|
|
|
|
g.UserResourceOwner = userOwner.String
|
|
|
|
g.FirstName = firstName.String
|
|
|
|
g.LastName = lastName.String
|
|
|
|
g.Email = email.String
|
|
|
|
g.DisplayName = displayName.String
|
|
|
|
g.AvatarURL = avatarURL.String
|
2022-03-24 13:00:24 +00:00
|
|
|
g.PreferredLoginName = preferredLoginName.String
|
2022-01-14 09:45:50 +00:00
|
|
|
g.OrgName = orgName.String
|
|
|
|
g.OrgPrimaryDomain = orgDomain.String
|
|
|
|
g.ProjectName = projectName.String
|
|
|
|
|
|
|
|
userGrants = append(userGrants, g)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "QUERY-iGvmP", "Errors.Query.CloseRows")
|
|
|
|
}
|
|
|
|
|
|
|
|
return &UserGrants{
|
|
|
|
UserGrants: userGrants,
|
|
|
|
SearchResponse: SearchResponse{
|
|
|
|
Count: count,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|