mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
6b3f5b984c
* refactor: switch from opencensus to opentelemetry * tempo works as designed nooooot * fix: log traceids * with grafana agent * fix: http tracing * fix: cleanup files * chore: remove todo * fix: bad test * fix: ignore methods in grpc interceptors * fix: remove test log * clean up * typo * fix(config): configure tracing endpoint * fix(span): add error id to span * feat: metrics package * feat: metrics package * fix: counter * fix: metric * try metrics * fix: coutner metrics * fix: active sessin counter * fix: active sessin counter * fix: change current Sequence table * fix: change current Sequence table * fix: current sequences * fix: spooler div metrics * fix: console view * fix: merge master * fix: Last spool run on search result instead of eventtimestamp * fix: go mod * Update console/src/assets/i18n/de.json Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr review * fix: map * update oidc pkg * fix: handlers * fix: value observer * fix: remove fmt * fix: handlers * fix: tests * fix: handler minimum cycle duration 1s * fix(spooler): handler channel buffer * fix interceptors Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
78 lines
2.3 KiB
Go
78 lines
2.3 KiB
Go
package view
|
|
|
|
import (
|
|
key_model "github.com/caos/zitadel/internal/key/model"
|
|
"github.com/caos/zitadel/internal/key/repository/view"
|
|
"github.com/caos/zitadel/internal/key/repository/view/model"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
keyTable = "auth.keys"
|
|
)
|
|
|
|
func (v *View) KeyByIDAndType(keyID string, private bool) (*model.KeyView, error) {
|
|
return view.KeyByIDAndType(v.Db, keyTable, keyID, private)
|
|
}
|
|
|
|
func (v *View) GetSigningKey() (*key_model.SigningKey, error) {
|
|
key, err := view.GetSigningKey(v.Db, keyTable)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return key_model.SigningKeyFromKeyView(model.KeyViewToModel(key), v.keyAlgorithm)
|
|
}
|
|
|
|
func (v *View) GetActiveKeySet() ([]*key_model.PublicKey, error) {
|
|
keys, err := view.GetActivePublicKeys(v.Db, keyTable)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return key_model.PublicKeysFromKeyView(model.KeyViewsToModel(keys), v.keyAlgorithm)
|
|
}
|
|
|
|
func (v *View) PutKeys(privateKey, publicKey *model.KeyView, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.PutKeys(v.Db, keyTable, privateKey, publicKey)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedKeySequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteKey(keyID string, private bool, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteKey(v.Db, keyTable, keyID, private)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedKeySequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteKeyPair(keyID string, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteKeyPair(v.Db, keyTable, keyID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedKeySequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) GetLatestKeySequence() (*repository.CurrentSequence, error) {
|
|
return v.latestSequence(keyTable)
|
|
}
|
|
|
|
func (v *View) ProcessedKeySequence(eventSequence uint64, eventTimestamp time.Time) error {
|
|
return v.saveCurrentSequence(keyTable, eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) UpdateKeySpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(keyTable)
|
|
}
|
|
|
|
func (v *View) GetLatestKeyFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
|
return v.latestFailedEvent(keyTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedKeyFailedEvent(failedEvent *repository.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|