feat: retain encrypted instance credentials and reissue v2 certificates
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
@@ -16,9 +16,10 @@ import (
|
||||
)
|
||||
|
||||
type BusinessAPI struct {
|
||||
db *sql.DB
|
||||
signingPrivateKeyPEM string
|
||||
keyring *Keyring
|
||||
db *sql.DB
|
||||
signingPrivateKeyPEM string
|
||||
keyring *Keyring
|
||||
credentialEncryptionKey []byte
|
||||
}
|
||||
|
||||
func secureSessionCookie(c *gin.Context) bool {
|
||||
@@ -35,11 +36,15 @@ func RegisterBusiness(r *gin.Engine, db *sql.DB, signingPrivateKeyPEM ...string)
|
||||
}
|
||||
registerBusinessRoutes(r, a)
|
||||
}
|
||||
func RegisterBusinessWithKeyring(r *gin.Engine, db *sql.DB, private string, ring *Keyring) {
|
||||
func RegisterBusinessWithKeyring(r *gin.Engine, db *sql.DB, private string, ring *Keyring, credentialKey ...[]byte) {
|
||||
if db == nil {
|
||||
return
|
||||
}
|
||||
registerBusinessRoutes(r, &BusinessAPI{db: db, signingPrivateKeyPEM: private, keyring: ring})
|
||||
a := &BusinessAPI{db: db, signingPrivateKeyPEM: private, keyring: ring}
|
||||
if len(credentialKey) > 0 {
|
||||
a.credentialEncryptionKey = credentialKey[0]
|
||||
}
|
||||
registerBusinessRoutes(r, a)
|
||||
}
|
||||
func registerBusinessRoutes(r *gin.Engine, a *BusinessAPI) {
|
||||
api := r.Group("/api/v1")
|
||||
@@ -87,6 +92,7 @@ func registerBusinessRoutes(r *gin.Engine, a *BusinessAPI) {
|
||||
secured.GET("/licenses/:id", a.getLicense)
|
||||
secured.GET("/licenses/:id/instances", a.listInstances)
|
||||
secured.POST("/licenses/:id/instances", a.provisionInstance)
|
||||
secured.GET("/licenses/:id/instance-credentials", a.instanceCredentials)
|
||||
secured.POST("/products/:id/releases", a.createRelease)
|
||||
secured.GET("/products/:id/releases", a.listReleases)
|
||||
api.POST("/customers/:customer_id/releases/:id/download", a.downloadRelease)
|
||||
|
||||
Reference in New Issue
Block a user