mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-05 14:37:45 +00:00
320679467b
* feat: change login to command side * feat: change login to command side * fix: fix push on user * feat: user command side * feat: sign out * feat: command side login * feat: command side login * feat: fix register user * feat: fix register user * feat: fix web auth n events * feat: add machine keys * feat: send codes * feat: move authrequest to domain * feat: move authrequest to domain * feat: webauthn working * feat: external users * feat: external users login * feat: notify users * fix: tests * feat: cascade remove user grants on project remove * fix: webauthn * fix: pr requests * fix: register human with member * fix: fix bugs * fix: fix bugs
58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package domain
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"time"
|
|
)
|
|
|
|
type MachineKey struct {
|
|
models.ObjectRoot
|
|
|
|
KeyID string
|
|
Type MachineKeyType
|
|
ExpirationDate time.Time
|
|
PrivateKey []byte
|
|
PublicKey []byte
|
|
}
|
|
|
|
type MachineKeyType int32
|
|
|
|
const (
|
|
MachineKeyTypeNONE = iota
|
|
MachineKeyTypeJSON
|
|
|
|
keyCount
|
|
)
|
|
|
|
type MachineKeyState int32
|
|
|
|
const (
|
|
MachineKeyStateUnspecified MachineKeyState = iota
|
|
MachineKeyStateActive
|
|
MachineKeyStateRemoved
|
|
|
|
machineKeyStateCount
|
|
)
|
|
|
|
func (f MachineKeyState) Valid() bool {
|
|
return f >= 0 && f < machineKeyStateCount
|
|
}
|
|
|
|
func (f MachineKeyType) Valid() bool {
|
|
return f >= 0 && f < keyCount
|
|
}
|
|
|
|
func (key *MachineKey) GenerateNewMachineKeyPair(keySize int) error {
|
|
privateKey, publicKey, err := crypto.GenerateKeyPair(keySize)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
key.PublicKey, err = crypto.PublicKeyToBytes(publicKey)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
key.PrivateKey = crypto.PrivateKeyToBytes(privateKey)
|
|
return nil
|
|
}
|