Skip to content

Commit

Permalink
Pulling in the bulk-delete branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caesonia committed Jan 30, 2024
2 parents f8ff028 + 13e2e79 commit 7c2bb05
Show file tree
Hide file tree
Showing 49 changed files with 1,493 additions and 661 deletions.
5 changes: 5 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ HTTPS_COOKIES=false
#
NSQ_URL='http://localhost:4151'

#
# Secret key required to perform batch deletions.
#
BATCH_DELETION_KEY="00000000-0000-0000-0000-000000000000"

#
# Two-Factor auth settings.
#
Expand Down
1 change: 1 addition & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# AUTHY_API_KEY
# AWS_SES_PWD
# AWS_SES_USER
# BATCH_DELETION_KEY
# COOKIE_BLOCK_KEY
# COOKIE_DOMAIN
# COOKIE_HASH_KEY
Expand Down
5 changes: 5 additions & 0 deletions .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ HTTPS_COOKIES=false
# items into queues.
NSQ_URL='http://localhost:4151'

#
# Secret key required to perform batch deletions.
#
BATCH_DELETION_KEY="00000000-0000-0000-0000-000000000000"

#
# Two-Factor auth settings.
#
Expand Down
5 changes: 5 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ HTTPS_COOKIES=false
# items into queues.
NSQ_URL='http://localhost:4151'

#
# Secret key required to perform batch deletions.
#
BATCH_DELETION_KEY="00000000-0000-0000-0000-000000000000"

#
# Two-Factor auth settings.
#
Expand Down
5 changes: 5 additions & 0 deletions .env.travis
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ HTTPS_COOKIES=false
#
NSQ_URL='http://localhost:4151'

#
# Secret key required to perform batch deletions.
#
BATCH_DELETION_KEY="00000000-0000-0000-0000-000000000000"

#
# Two-Factor auth settings.
#
Expand Down
5 changes: 5 additions & 0 deletions .env.uidemo
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ HTTPS_COOKIES=true
#
NSQ_URL='http://localhost:4151'

#
# Secret key required to perform batch deletions.
#
BATCH_DELETION_KEY="00000000-0000-0000-0000-000000000000"

#
# Two-Factor auth settings.
#
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.multi
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ ENV LOG_TO_CONSOLE=true
ENV LOG_SQL=false
ENV AWS_SES_PWD=password
ENV [email protected]
ENV BATCH_DELETION_KEY=key

ENV BATCH_DELETION_KEY=66f93cdf-8c25-4693-8990-68ab415a1449
# Making a note for a new dockerfile test.
EXPOSE 8080

Expand Down
6 changes: 5 additions & 1 deletion alert_templates/deletion_confirmed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ For your reference, the link below has information about the request.

{{ .deletionReadOnlyURL }}

The Work Item showing the status of this deletion is at {{ .workItemURL }}
The Work Items showing the status of this deletion are at

{{ range $index, $itemUrl := .workItemURLs }}
{{ $itemUrl }}
{{ end }}

If you have questions, please contact us at [email protected].

Expand Down
1 change: 1 addition & 0 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func initRoutes(router *gin.Engine) {
adminAPI.PUT("/objects/update/:id", admin_api.IntellectualObjectUpdate)
adminAPI.DELETE("/objects/delete/:id", admin_api.IntellectualObjectDelete)
adminAPI.POST("/objects/init_restore/:id", admin_api.IntellectualObjectInitRestore)
adminAPI.POST("/objects/init_batch_delete", admin_api.IntellectualObjectInitBatchDelete)

// Premis Events
adminAPI.POST("/events/create", admin_api.PremisEventCreate)
Expand Down
20 changes: 11 additions & 9 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ type RedisConfig struct {
}

type Config struct {
Cookies *CookieConfig
DB *DBConfig
EnvName string
Logging *LoggingConfig
NsqUrl string
TwoFactor *TwoFactorConfig
Email *EmailConfig
Redis *RedisConfig
Cookies *CookieConfig
DB *DBConfig
EnvName string
Logging *LoggingConfig
NsqUrl string
TwoFactor *TwoFactorConfig
Email *EmailConfig
Redis *RedisConfig
BatchDeletionKey string
}

// Returns a new config based on APT_ENV
Expand Down Expand Up @@ -181,7 +182,8 @@ func loadConfig() *Config {
FlashCookie: v.GetString("FLASH_COOKIE_NAME"),
PrefsCookie: v.GetString("PREFS_COOKIE_NAME"),
},
NsqUrl: nsqUrl,
NsqUrl: nsqUrl,
BatchDeletionKey: v.GetString("BATCH_DELETION_KEY"),
TwoFactor: &TwoFactorConfig{
AuthyAPIKey: v.GetString("AUTHY_API_KEY"),
AuthyEnabled: v.GetBool("ENABLE_TWO_FACTOR_AUTHY"),
Expand Down
8 changes: 8 additions & 0 deletions common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ var ErrCountTypeNotSupported = errors.New("type is not supported for view count"
// but they shouldn't be doing it in this context.
var ErrMustCompleteReset = errors.New("you must complete your own password reset")

// ErrInvalidObjectID occurs when requesting a batch deletion that
// contains one or more invalid object ids.
var ErrInvalidObjectID = errors.New("one or more object ids is invalid")

// ErrInvalidRequestorID occurs when APTrust admin submits batch delete
// request on behalf of a user who is not allowed to initiate a batch deletion.
var ErrInvalidRequestorID = errors.New("invalid requestor id")

type ValidationError struct {
Errors map[string]string
}
Expand Down
3 changes: 3 additions & 0 deletions constants/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
InstitutionRead = "InstitutionRead"
InstitutionUpdate = "InstitutionUpdate"
InstitutionUpdatePrefs = "InstitutionUpdatePrefs"
IntellectualObjectBatchDelete = "IntellectualObjectBatchDelete"
IntellectualObjectCreate = "IntellectualObjectCreate"
IntellectualObjectDelete = "IntellectualObjectDelete"
IntellectualObjectFinishBulkDelete = "IntellectualObjectFinishBulkDelete"
Expand Down Expand Up @@ -124,6 +125,7 @@ var Permissions = []Permission{
InstitutionRead,
InstitutionUpdate,
InstitutionUpdatePrefs,
IntellectualObjectBatchDelete,
IntellectualObjectCreate,
IntellectualObjectDelete,
IntellectualObjectFinishBulkDelete,
Expand Down Expand Up @@ -311,6 +313,7 @@ func initPermissions() {
sysAdmin[InstitutionRead] = true
sysAdmin[InstitutionUpdate] = true
sysAdmin[InstitutionUpdatePrefs] = true
sysAdmin[IntellectualObjectBatchDelete] = true
sysAdmin[IntellectualObjectCreate] = true
sysAdmin[IntellectualObjectDelete] = true // preserv workers do this with sys admin account
sysAdmin[IntellectualObjectFinishBulkDelete] = true // not implemented yet
Expand Down
8 changes: 4 additions & 4 deletions db/fixtures/deletion_requests.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"id","institution_id","requested_by_id","requested_at","encrypted_confirmation_token","confirmed_by_id","confirmed_at","cancelled_by_id","cancelled_at","work_item_id"
1,2,3,2021-05-13 11:10:32,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,,,,,
2,2,3,2021-05-13 11:10:33,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,2,2021-05-13 11:10:33,,,
3,2,3,2021-05-13 11:10:34,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,,,2,2021-05-13 11:10:34,
"id","institution_id","requested_by_id","requested_at","encrypted_confirmation_token","confirmed_by_id","confirmed_at","cancelled_by_id","cancelled_at"
1,2,3,2021-05-13 11:10:32,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,,,,
2,2,3,2021-05-13 11:10:33,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,2,2021-05-13 11:10:33,,
3,2,3,2021-05-13 11:10:34,$2a$10$TK8s1XnmWulSUdze8GN5uOgGmDDsnndQKF5/Rz1j0xaHT7AwXRVma,,,2,2021-05-13 11:10:34
Loading

0 comments on commit 7c2bb05

Please sign in to comment.