fix: rename iam to instance (#3345)

* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename iam command side to instance

* fix: rename orgiampolicy to domain policy

* fix: merge conflicts

* fix: protos

* fix: md files

* implement deprecated org iam policy again

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2022-03-24 17:21:34 +01:00
committed by GitHub
parent 504fe5b761
commit 9d4f296c62
274 changed files with 12073 additions and 11853 deletions

View File

@@ -15,7 +15,7 @@ import (
"github.com/caos/zitadel/internal/query/projection"
)
type OrgIAMPolicy struct {
type DomainPolicy struct {
ID string
Sequence uint64
CreationDate time.Time
@@ -29,64 +29,64 @@ type OrgIAMPolicy struct {
}
var (
orgIAMTable = table{
name: projection.OrgIAMPolicyTable,
domainPolicyTable = table{
name: projection.DomainPolicyTable,
}
OrgIAMColID = Column{
name: projection.OrgIAMPolicyIDCol,
table: orgIAMTable,
DomainPolicyColID = Column{
name: projection.DomainPolicyIDCol,
table: domainPolicyTable,
}
OrgIAMColSequence = Column{
name: projection.OrgIAMPolicySequenceCol,
table: orgIAMTable,
DomainPolicyColSequence = Column{
name: projection.DomainPolicySequenceCol,
table: domainPolicyTable,
}
OrgIAMColCreationDate = Column{
name: projection.OrgIAMPolicyCreationDateCol,
table: orgIAMTable,
DomainPolicyColCreationDate = Column{
name: projection.DomainPolicyCreationDateCol,
table: domainPolicyTable,
}
OrgIAMColChangeDate = Column{
name: projection.OrgIAMPolicyChangeDateCol,
table: orgIAMTable,
DomainPolicyColChangeDate = Column{
name: projection.DomainPolicyChangeDateCol,
table: domainPolicyTable,
}
OrgIAMColResourceOwner = Column{
name: projection.OrgIAMPolicyResourceOwnerCol,
table: orgIAMTable,
DomainPolicyColResourceOwner = Column{
name: projection.DomainPolicyResourceOwnerCol,
table: domainPolicyTable,
}
OrgIAMColInstanceID = Column{
name: projection.OrgIAMPolicyInstanceIDCol,
table: orgIAMTable,
DomainPolicyColInstanceID = Column{
name: projection.DomainPolicyInstanceIDCol,
table: domainPolicyTable,
}
OrgIAMColUserLoginMustBeDomain = Column{
name: projection.OrgIAMPolicyUserLoginMustBeDomainCol,
table: orgIAMTable,
DomainPolicyColUserLoginMustBeDomain = Column{
name: projection.DomainPolicyUserLoginMustBeDomainCol,
table: domainPolicyTable,
}
OrgIAMColIsDefault = Column{
name: projection.OrgIAMPolicyIsDefaultCol,
table: orgIAMTable,
DomainPolicyColIsDefault = Column{
name: projection.DomainPolicyIsDefaultCol,
table: domainPolicyTable,
}
OrgIAMColState = Column{
name: projection.OrgIAMPolicyStateCol,
table: orgIAMTable,
DomainPolicyColState = Column{
name: projection.DomainPolicyStateCol,
table: domainPolicyTable,
}
)
func (q *Queries) OrgIAMPolicyByOrg(ctx context.Context, orgID string) (*OrgIAMPolicy, error) {
stmt, scan := prepareOrgIAMPolicyQuery()
func (q *Queries) DomainPolicyByOrg(ctx context.Context, orgID string) (*DomainPolicy, error) {
stmt, scan := prepareDomainPolicyQuery()
query, args, err := stmt.Where(
sq.And{
sq.Eq{
OrgIAMColInstanceID.identifier(): authz.GetInstance(ctx).ID,
DomainPolicyColInstanceID.identifier(): authz.GetInstance(ctx).ID,
},
sq.Or{
sq.Eq{
OrgIAMColID.identifier(): orgID,
DomainPolicyColID.identifier(): orgID,
},
sq.Eq{
OrgIAMColID.identifier(): domain.IAMID,
DomainPolicyColID.identifier(): domain.IAMID,
},
},
}).
OrderBy(OrgIAMColIsDefault.identifier()).
OrderBy(DomainPolicyColIsDefault.identifier()).
Limit(1).ToSql()
if err != nil {
return nil, errors.ThrowInternal(err, "QUERY-D3CqT", "Errors.Query.SQLStatement")
@@ -96,13 +96,13 @@ func (q *Queries) OrgIAMPolicyByOrg(ctx context.Context, orgID string) (*OrgIAMP
return scan(row)
}
func (q *Queries) DefaultOrgIAMPolicy(ctx context.Context) (*OrgIAMPolicy, error) {
stmt, scan := prepareOrgIAMPolicyQuery()
func (q *Queries) DefaultDomainPolicy(ctx context.Context) (*DomainPolicy, error) {
stmt, scan := prepareDomainPolicyQuery()
query, args, err := stmt.Where(sq.Eq{
OrgIAMColID.identifier(): domain.IAMID,
OrgIAMColInstanceID.identifier(): authz.GetInstance(ctx).ID,
DomainPolicyColID.identifier(): domain.IAMID,
DomainPolicyColInstanceID.identifier(): authz.GetInstance(ctx).ID,
}).
OrderBy(OrgIAMColIsDefault.identifier()).
OrderBy(DomainPolicyColIsDefault.identifier()).
Limit(1).ToSql()
if err != nil {
return nil, errors.ThrowInternal(err, "QUERY-pM7lP", "Errors.Query.SQLStatement")
@@ -112,20 +112,20 @@ func (q *Queries) DefaultOrgIAMPolicy(ctx context.Context) (*OrgIAMPolicy, error
return scan(row)
}
func prepareOrgIAMPolicyQuery() (sq.SelectBuilder, func(*sql.Row) (*OrgIAMPolicy, error)) {
func prepareDomainPolicyQuery() (sq.SelectBuilder, func(*sql.Row) (*DomainPolicy, error)) {
return sq.Select(
OrgIAMColID.identifier(),
OrgIAMColSequence.identifier(),
OrgIAMColCreationDate.identifier(),
OrgIAMColChangeDate.identifier(),
OrgIAMColResourceOwner.identifier(),
OrgIAMColUserLoginMustBeDomain.identifier(),
OrgIAMColIsDefault.identifier(),
OrgIAMColState.identifier(),
DomainPolicyColID.identifier(),
DomainPolicyColSequence.identifier(),
DomainPolicyColCreationDate.identifier(),
DomainPolicyColChangeDate.identifier(),
DomainPolicyColResourceOwner.identifier(),
DomainPolicyColUserLoginMustBeDomain.identifier(),
DomainPolicyColIsDefault.identifier(),
DomainPolicyColState.identifier(),
).
From(orgIAMTable.identifier()).PlaceholderFormat(sq.Dollar),
func(row *sql.Row) (*OrgIAMPolicy, error) {
policy := new(OrgIAMPolicy)
From(domainPolicyTable.identifier()).PlaceholderFormat(sq.Dollar),
func(row *sql.Row) (*DomainPolicy, error) {
policy := new(DomainPolicy)
err := row.Scan(
&policy.ID,
&policy.Sequence,
@@ -138,7 +138,7 @@ func prepareOrgIAMPolicyQuery() (sq.SelectBuilder, func(*sql.Row) (*OrgIAMPolicy
)
if err != nil {
if errs.Is(err, sql.ErrNoRows) {
return nil, errors.ThrowNotFound(err, "QUERY-K0Jr5", "Errors.OrgIAMPolicy.NotFound")
return nil, errors.ThrowNotFound(err, "QUERY-K0Jr5", "Errors.DomainPolicy.NotFound")
}
return nil, errors.ThrowInternal(err, "QUERY-rIy6j", "Errors.Internal")
}