Skip to content

Commit

Permalink
wip: create accoun signing keys
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored May 14, 2024
1 parent 3f17218 commit 109fcd3
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/api/adapters/db/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// GetAccount ...
func (db *DB) GetAccount(ctx context.Context, account *models.Account) error {
return db.conn.WithContext(ctx).Preload("Token").Preload("Operator").Preload("SigningKeyGroups").Preload("SigningKeyGroups.Key").Preload("Key").First(account).Error
return db.conn.WithContext(ctx).Preload("Token").Preload("SigningKeyGroups").Preload("SigningKeyGroups.Key").Preload("Key").First(account).Error
}

// CreateAccount ...
Expand Down
2 changes: 1 addition & 1 deletion internal/api/adapters/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (db *DB) RunMigrations() error {
&adapters.Account{},
&adapters.Session{},
&models.User{},
&models.Account{},
&models.Operator{},
&models.Account{},
&models.System{},
&models.Tag{},
&models.Ownership{},
Expand Down
2 changes: 1 addition & 1 deletion internal/api/controllers/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *accountsController) CreateAccount(ctx context.Context, cmd CreateAccoun
ac := jwt.NewAccountClaims(id)
ac.Name = cmd.Name
ac.Issuer = operator.KeyID
ac.SigningKeys.Add(skg.KeyID)
ac.SigningKeys.Add(skg.Key.ID)

token, err := ac.Encode(osk)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions internal/api/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type Account struct {
TokenID string `json:"token_id"`
// OperatorID is the operator ID.
OperatorID uuid.UUID `json:"operator_id"`
// Operator is the operator that owns the account.
Operator Operator `json:"operator" gorm:"foreignKey:OperatorID"`
// SigningKeyGroups is the list of signing key groups the account has.
SigningKeyGroups []SigningKeyGroup `json:"signing_key_groups" gorm:"many2many:account_signing_key_groups;foreignKey:ID;joinForeignKey:AccountID;joinReferences:SigningKeyGroupID"`
// SignedBy is the entity that signs this one.
Expand Down
6 changes: 2 additions & 4 deletions internal/api/models/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ type Operator struct {
// SystemAdminAccount is the account that is used to manage the systems.
SystemAdminAccount *Account `json:"system_admin_account" gorm:"foreignKey:SystemAdminAccountID"`
SystemAdminAccountID *uuid.UUID `json:"system_admin_account_id"`
// Systems is the list of systems that the operator has.
Systems []System `json:"systems" gorm:"many2many:operator_systems;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:SystemID"`
// Accounts is the list of accounts that the operator has.
Accounts []Account `json:"accounts" gorm:"many2many:operator_accounts;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:AccountID"`
// Systems is the systems that are associated with the operator.
Systems []System `json:"systems" gorm:"foreignKey:OperatorID"`
// SigningKeyGroups is the list of signing key groups the account has.
SigningKeyGroups []SigningKeyGroup `json:"signing_key_groups" gorm:"many2many:operator_signing_key_groups;foreignKey:ID;joinForeignKey:OperatorID;joinReferences:SigningKeyGroupID"`
// CreatedAt is the time the operator was created.
Expand Down
2 changes: 1 addition & 1 deletion internal/api/models/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type System struct {
Clusters []Cluster `json:"clusters" gorm:"foreignKey:SystemID"`

// Operator is the operator this is associated with this system to operate.
Operator *Operator `json:"operator" gorm:"foreignKey:OperatorID"`
Operator Operator `json:"operator" gorm:"foreignKey:OperatorID"`
OperatorID uuid.UUID `json:"operator_id"`

// Tags is the tags that are associated with the system.
Expand Down

0 comments on commit 109fcd3

Please sign in to comment.