mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
fix: migration, key rotation and org event reducing (#1403)
* fix: migration, key rotation and org event reducing * fix oidc app * pointer receiver name
This commit is contained in:
parent
c71a30de76
commit
87a2e18a4d
@ -276,7 +276,11 @@ func (u *UserMembership) getOrgByID(ctx context.Context, orgID string) (*org_mod
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var esOrg *org_es_model.Org
|
esOrg := &org_es_model.Org{
|
||||||
|
ObjectRoot: es_models.ObjectRoot{
|
||||||
|
AggregateID: orgID,
|
||||||
|
},
|
||||||
|
}
|
||||||
err = es_sdk.Filter(ctx, u.Eventstore().FilterEvents, esOrg.AppendEvents, query)
|
err = es_sdk.Filter(ctx, u.Eventstore().FilterEvents, esOrg.AppendEvents, query)
|
||||||
if err != nil && !errors.IsNotFound(err) {
|
if err != nil && !errors.IsNotFound(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -41,24 +41,24 @@ type OIDCApp struct {
|
|||||||
State AppState
|
State AppState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OIDCApp) GetApplicationName() string {
|
func (a *OIDCApp) GetApplicationName() string {
|
||||||
return h.AppName
|
return a.AppName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OIDCApp) GetState() AppState {
|
func (a *OIDCApp) GetState() AppState {
|
||||||
return h.State
|
return a.State
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OIDCApp) setClientID(clientID string) {
|
func (a *OIDCApp) setClientID(clientID string) {
|
||||||
h.ClientID = clientID
|
a.ClientID = clientID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OIDCApp) setClientSecret(clientSecret *crypto.CryptoValue) {
|
func (a *OIDCApp) setClientSecret(clientSecret *crypto.CryptoValue) {
|
||||||
h.ClientSecret = clientSecret
|
a.ClientSecret = clientSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h OIDCApp) requiresClientSecret() bool {
|
func (a *OIDCApp) requiresClientSecret() bool {
|
||||||
return h.AuthMethodType == OIDCAuthMethodTypeBasic || h.AuthMethodType == OIDCAuthMethodTypePost
|
return a.AuthMethodType == OIDCAuthMethodTypeBasic || a.AuthMethodType == OIDCAuthMethodTypePost
|
||||||
}
|
}
|
||||||
|
|
||||||
type OIDCVersion int32
|
type OIDCVersion int32
|
||||||
@ -112,10 +112,10 @@ const (
|
|||||||
OIDCTokenTypeJWT
|
OIDCTokenTypeJWT
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *OIDCApp) IsValid() bool {
|
func (a *OIDCApp) IsValid() bool {
|
||||||
grantTypes := c.getRequiredGrantTypes()
|
grantTypes := a.getRequiredGrantTypes()
|
||||||
for _, grantType := range grantTypes {
|
for _, grantType := range grantTypes {
|
||||||
ok := containsOIDCGrantType(c.GrantTypes, grantType)
|
ok := containsOIDCGrantType(a.GrantTypes, grantType)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -123,10 +123,10 @@ func (c *OIDCApp) IsValid() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OIDCApp) getRequiredGrantTypes() []OIDCGrantType {
|
func (a *OIDCApp) getRequiredGrantTypes() []OIDCGrantType {
|
||||||
grantTypes := make([]OIDCGrantType, 0)
|
grantTypes := make([]OIDCGrantType, 0)
|
||||||
implicit := false
|
implicit := false
|
||||||
for _, r := range c.ResponseTypes {
|
for _, r := range a.ResponseTypes {
|
||||||
switch r {
|
switch r {
|
||||||
case OIDCResponseTypeCode:
|
case OIDCResponseTypeCode:
|
||||||
grantTypes = append(grantTypes, OIDCGrantTypeAuthorizationCode)
|
grantTypes = append(grantTypes, OIDCGrantTypeAuthorizationCode)
|
||||||
@ -149,8 +149,8 @@ func containsOIDCGrantType(grantTypes []OIDCGrantType, grantType OIDCGrantType)
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OIDCApp) FillCompliance() {
|
func (a *OIDCApp) FillCompliance() {
|
||||||
c.Compliance = GetOIDCCompliance(c.OIDCVersion, c.ApplicationType, c.GrantTypes, c.ResponseTypes, c.AuthMethodType, c.RedirectUris)
|
a.Compliance = GetOIDCCompliance(a.OIDCVersion, a.ApplicationType, a.GrantTypes, a.ResponseTypes, a.AuthMethodType, a.RedirectUris)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOIDCCompliance(version OIDCVersion, appType OIDCApplicationType, grantTypes []OIDCGrantType, responseTypes []OIDCResponseType, authMethod OIDCAuthMethodType, redirectUris []string) *Compliance {
|
func GetOIDCCompliance(version OIDCVersion, appType OIDCApplicationType, grantTypes []OIDCGrantType, responseTypes []OIDCResponseType, authMethod OIDCAuthMethodType, redirectUris []string) *Compliance {
|
||||||
|
@ -3,9 +3,11 @@ package view
|
|||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/eventstore"
|
"github.com/caos/zitadel/internal/eventstore"
|
||||||
"github.com/caos/zitadel/internal/repository/iam"
|
"github.com/caos/zitadel/internal/repository/iam"
|
||||||
|
"github.com/caos/zitadel/internal/repository/keypair"
|
||||||
)
|
)
|
||||||
|
|
||||||
func KeyPairQuery(latestSequence uint64) *eventstore.SearchQueryBuilder {
|
func KeyPairQuery(latestSequence uint64) *eventstore.SearchQueryBuilder {
|
||||||
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
|
||||||
SequenceGreater(latestSequence)
|
SequenceGreater(latestSequence).
|
||||||
|
EventTypes(keypair.AddedEventType)
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,11 @@ func (u *NotifyUser) getOrgByID(ctx context.Context, orgID string) (*org_model.O
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var esOrg *org_es_model.Org
|
esOrg := &org_es_model.Org{
|
||||||
|
ObjectRoot: es_models.ObjectRoot{
|
||||||
|
AggregateID: orgID,
|
||||||
|
},
|
||||||
|
}
|
||||||
err = es_sdk.Filter(ctx, u.Eventstore().FilterEvents, esOrg.AppendEvents, query)
|
err = es_sdk.Filter(ctx, u.Eventstore().FilterEvents, esOrg.AppendEvents, query)
|
||||||
if err != nil && !caos_errs.IsNotFound(err) {
|
if err != nil && !caos_errs.IsNotFound(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package usergrant
|
package keypair
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/eventstore"
|
"github.com/caos/zitadel/internal/eventstore"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package usergrant
|
package keypair
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/caos/zitadel/internal/eventstore"
|
"github.com/caos/zitadel/internal/eventstore"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package usergrant
|
package keypair
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
CREATE USER queries WITH PASSWORD ${queriespassword};
|
CREATE USER queries WITH PASSWORD ${queriespassword};
|
||||||
GRANT SELECT ON DATABASE eventstore TO queries;
|
GRANT SELECT ON TABLE eventstore.events TO queries;
|
||||||
|
Loading…
Reference in New Issue
Block a user