fix: change to repository event types and removed unused code (#3386)

* fix: change to repository event types and removed unused code

* some fixes

* remove unused code
This commit is contained in:
Livio Amstutz
2022-03-31 11:36:26 +02:00
committed by GitHub
parent 55af4a18a2
commit 87560157c1
170 changed files with 999 additions and 9581 deletions

View File

@@ -8,9 +8,9 @@ import (
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
key_model "github.com/caos/zitadel/internal/key/model"
"github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/repository/project"
)
type OIDCConfig struct {
@@ -75,38 +75,18 @@ func (key *ClientKey) AppendEvents(events ...*es_models.Event) error {
func (key *ClientKey) AppendEvent(event *es_models.Event) (err error) {
key.ObjectRoot.AppendEvent(event)
switch event.Type {
case ClientKeyAdded:
switch eventstore.EventType(event.Type) {
case project.ApplicationKeyAddedEventType:
err = json.Unmarshal(event.Data, key)
if err != nil {
return errors.ThrowInternal(err, "MODEL-Fetg3", "Errors.Internal")
}
case ClientKeyRemoved:
case project.ApplicationKeyRemovedEventType:
key.ExpirationDate = event.CreationDate
}
return err
}
func ClientKeysToModel(keys []*ClientKey) []*model.ClientKey {
clientKeys := make([]*model.ClientKey, len(keys))
for i, key := range keys {
clientKeys[i] = ClientKeyToModel(key)
}
return clientKeys
}
func ClientKeyToModel(key *ClientKey) *model.ClientKey {
return &model.ClientKey{
ObjectRoot: key.ObjectRoot,
ExpirationDate: key.ExpirationDate,
ApplicationID: key.ApplicationID,
ClientID: key.ClientID,
KeyID: key.KeyID,
PrivateKey: key.privateKey,
Type: key_model.AuthNKeyType(key.Type),
}
}
func (key *ClientKey) GenerateClientKeyPair(keySize int) error {
privateKey, publicKey, err := crypto.GenerateKeyPair(keySize)
if err != nil {