fix(release,webhooks): Fixed retrieval of encrypted webhook token and prepare patch 2.0.1 release
This commit is contained in:
parent
c1631a0588
commit
98b37ca289
2 changed files with 37 additions and 8 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -2,18 +2,20 @@
|
|||
|
||||
Changes adhere to [semantic versioning](https://semver.org).
|
||||
|
||||
## [2.0.1] - UNRELEASED
|
||||
## [2.0.1] - 2024/05/01
|
||||
|
||||
* ...
|
||||
* Fixed retrieval of encrypted webhook token
|
||||
|
||||
## [2.0.0] - 2024/04/28
|
||||
|
||||
> This is a major version upgrade. Other versions are incompatible with this release.
|
||||
|
||||
* Added _Actions_, a simple way to trigger notifications via [shoutrrr](https://containrrr.dev/shoutrrr) which supports secrets
|
||||
* Added _Actions_, a simple way to trigger notifications via [shoutrrr](https://containrrr.dev/shoutrrr) which supports
|
||||
secrets
|
||||
* Added new auth mode which allows setting multiple basic auth credentials
|
||||
* Added `AUTH_MODE` which can be one of `basic_single` (_default_) and `basic_credentials`
|
||||
* For `basic_credentials`: added `BASIC_AUTH_CREDENTIALS` which can be used as list of `username1=password1,...` (comma separated)
|
||||
* For `basic_credentials`: added `BASIC_AUTH_CREDENTIALS` which can be used as list of `username1=password1,...` (
|
||||
comma separated)
|
||||
* For `basic_single`: renamed `ADMIN_USER` and `ADMIN_PASSWORD` to `BASIC_AUTH_USER` and `BASIC_AUTH_PASSWORD`
|
||||
* Added mandatory `SECRET` environment variable to encrypt some data inside the database
|
||||
* Switched to producing events only for _Updates_
|
||||
|
@ -43,6 +45,8 @@ Changes adhere to [semantic versioning](https://semver.org).
|
|||
|
||||
* Initial release
|
||||
|
||||
[2.0.1]: https://git.myservermanager.com/varakh/upda/releases/tag/2.0.1
|
||||
|
||||
[2.0.0]: https://git.myservermanager.com/varakh/upda/releases/tag/2.0.0
|
||||
|
||||
[1.0.3]: https://git.myservermanager.com/varakh/upda/releases/tag/1.0.3
|
||||
|
|
|
@ -26,7 +26,7 @@ type Update struct {
|
|||
UpdatedAt time.Time `gorm:"time;autoUpdateTime;not null"`
|
||||
}
|
||||
|
||||
// BeforeCreate encrypts secret value before storing to database
|
||||
// BeforeCreate encrypts webhook token before storing to database
|
||||
func (wh *Webhook) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
var er error
|
||||
var encryptedToken string
|
||||
|
@ -40,7 +40,20 @@ func (wh *Webhook) BeforeCreate(tx *gorm.DB) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// AfterSave decrypt secret value after encrypted value has been retrieved from database
|
||||
// BeforeUpdate encrypts webhook token before storing to database
|
||||
func (wh *Webhook) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||
var er error
|
||||
var encryptedValue string
|
||||
|
||||
if encryptedValue, er = util.EncryptAndEncode(wh.Token, os.Getenv(envSecret)); er != nil {
|
||||
return er
|
||||
}
|
||||
|
||||
wh.Token = encryptedValue
|
||||
return
|
||||
}
|
||||
|
||||
// AfterSave decrypt webhook token after encrypted value has been retrieved from database
|
||||
func (wh *Webhook) AfterSave(tx *gorm.DB) (err error) {
|
||||
var er error
|
||||
var decrypted string
|
||||
|
@ -52,6 +65,18 @@ func (wh *Webhook) AfterSave(tx *gorm.DB) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// AfterFind decrypt webhook token after encrypted value has been retrieved from database
|
||||
func (wh *Webhook) AfterFind(tx *gorm.DB) (err error) {
|
||||
var er error
|
||||
var decrypted string
|
||||
if decrypted, er = util.DecryptAndDecode(wh.Token, os.Getenv(envSecret)); er != nil {
|
||||
return er
|
||||
}
|
||||
|
||||
wh.Token = decrypted
|
||||
return
|
||||
}
|
||||
|
||||
// Webhook entity holding information for webhooks
|
||||
type Webhook struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;unique;not null"`
|
||||
|
|
Loading…
Reference in a new issue