Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 81e2022

Browse files
committed
Remove all secrets routes
1 parent 27a32c3 commit 81e2022

File tree

9 files changed

+6
-482
lines changed

9 files changed

+6
-482
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ BACKUP_S3_ACCESS_KEY_ID=
2727
BACKUP_S3_SECRET_ACCESS_KEY=
2828
BACKUP_S3_BUCKET=rtcv-backups
2929
BACKUP_S3_USE_SSL=true
30-

controller/api_keys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ func middlewareBindMyKey() routeBuilder.M {
216216
}
217217
}
218218

219-
func middlewareBindKey() routeBuilder.M {
219+
func middlewareBindKey(urlParamName string) routeBuilder.M {
220220
return routeBuilder.M{
221221
Fn: func(c *fiber.Ctx) error {
222-
keyParam := c.Params(`keyID`)
222+
keyParam := c.Params(urlParamName)
223223
keyID, err := primitive.ObjectIDFromHex(keyParam)
224224
if err != nil {
225225
return err

controller/controller.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,11 @@ func Routes(app *fiber.App, appVersion string, testing bool) {
4040
})
4141
}, requiresAuth(models.APIKeyRoleScraper|models.APIKeyRoleDashboard))
4242

43-
secretsRoutes := func(b *routeBuilder.Router) {
44-
b.Get(``, routeGetSecrets)
45-
b.Group(`/:key`, func(b *routeBuilder.Router) {
46-
b.Delete(``, routeDeleteSecret, validKeyMiddleware())
47-
b.Put(``, routeUpdateOrCreateSecret)
48-
b.Get(`/:encryptionKey`, routeGetSecret, validKeyMiddleware())
49-
})
50-
}
51-
b.Group(`/secrets`, func(b *routeBuilder.Router) {
52-
b.Group(`/myKey`,
53-
secretsRoutes,
54-
requiresAuth(models.APIKeyRoleAll),
55-
middlewareBindMyKey(),
56-
)
57-
b.Group(`/otherKey`, func(b *routeBuilder.Router) {
58-
// This route exposes a lot of user information that's why only the dashboard role can access it
59-
b.Get(``, routeGetAllSecretsFromAllKeys, requiresAuth(models.APIKeyRoleDashboard))
60-
b.Group(
61-
`/:keyID`,
62-
secretsRoutes,
63-
middlewareBindKey(),
64-
requiresAuth(models.APIKeyRoleInformationObtainer|models.APIKeyRoleDashboard),
65-
)
66-
})
67-
})
68-
b.Group(`/scraperUsers/:keyID`, func(b *routeBuilder.Router) {
43+
b.Group(`/scraperUsers/:scraperKeyID`, func(b *routeBuilder.Router) {
6944
b.Get(``, routeGetScraperUsers)
7045
b.Patch(``, routePatchScraperUser, requiresAuth(models.APIKeyRoleAdmin|models.APIKeyRoleDashboard|models.APIKeyRoleController))
7146
b.Delete(``, routeDeleteScraperUser, requiresAuth(models.APIKeyRoleAdmin|models.APIKeyRoleDashboard|models.APIKeyRoleController))
72-
}, middlewareBindKey(), requiresAuth(models.APIKeyRoleAll))
47+
}, middlewareBindKey("scraperKeyID"), requiresAuth(models.APIKeyRoleAll))
7348

7449
b.Group(`/profiles`, func(b *routeBuilder.Router) {
7550
// Profile routes that required the information obtainer role
@@ -98,7 +73,7 @@ func Routes(app *fiber.App, appVersion string, testing bool) {
9873
b.Get(``, routeGetKey)
9974
b.Put(``, routeUpdateKey)
10075
b.Delete(``, routeDeleteKey)
101-
}, middlewareBindKey())
76+
}, middlewareBindKey("keyID"))
10277
}, requiresAuth(models.APIKeyRoleDashboard))
10378

10479
b.Group(`/onMatchHooks`, func(b *routeBuilder.Router) {

controller/matcher_tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ type RouteDeleteMatcherBranchResult struct {
143143

144144
var routeDeleteMatcherBranch = routeBuilder.R{
145145
Description: `remove a spesific branch and it's children`,
146-
Res: RouteDeleteSecretOkRes{},
146+
Res: RouteDeleteMatcherBranchResult{},
147147
Fn: func(c *fiber.Ctx) error {
148148
idParam := c.Params("id")
149149
id, err := primitive.ObjectIDFromHex(idParam)

controller/secrets.go

Lines changed: 0 additions & 185 deletions
This file was deleted.

controller/secrets_test.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func main() {
100100
dbConn.RegisterEntries(
101101
&models.APIKey{},
102102
&models.Profile{},
103-
&models.Secret{},
104103
&models.Backup{},
105104
&models.OnMatchHook{},
106105
&matcher.Branch{},

mock/mock.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,26 +179,6 @@ func NewMockDB() *testingdb.TestConnection {
179179
DashboardKey,
180180
)
181181

182-
// Insert secrets
183-
conn.UnsafeInsert(
184-
models.UnsafeMustCreateSecret(
185-
Key1.ID,
186-
"foo",
187-
"very-secret-key-of-more-than-16-chars",
188-
[]byte(`{"foo": 1}`),
189-
"test secret 1 from mock data",
190-
models.SecretValueStructureFree,
191-
),
192-
models.UnsafeMustCreateSecret(
193-
Key2.ID,
194-
"bar",
195-
"very-secret-key-of-more-than-16-chars",
196-
[]byte(`{"username": "foo", "password": "bar"}`),
197-
"test secret 2 from mock data",
198-
models.SecretValueStructureUser,
199-
),
200-
)
201-
202182
// Insert profiles
203183
conn.UnsafeInsert(
204184
Profile1,

0 commit comments

Comments
 (0)