Skip to content

Commit 263f8ac

Browse files
authored
internal endpoints part 2 (#2322)
* changes * read and write working * add lightstream example * query wip * EOD wip * add db types, modular bucket, auth * remove duplicates * remove noop store * remove unit ls-fast test command * remove units fast from the client * remove WAL setup * remove unnecessary * adjust auth * wip - mssql fix * enable NULL for lock time * some changes to documentation * Test Suite for query engine, adjustments to stores Discovered a flaw in sqlstore's handling of wildcard perms during testing, adjusted Adjustd the s3 store to enable testing with this definition instead of separate mock Added tests for different aspects of the query engine, especially rbac and unit management. * fix docker warnings and build fail * add missing syncs for rbac * adjust docs, silence SQL logs, check for existence before sync * adjust docs - PATH to DB_PATH, add prefix * refactor with repository in mind * add webhook auth, internal routing * some how have double models.go after merging * add constant time check, verify org, other corrections * revert, other adjustments * restore from develop * remove comment * change webhook secrete to opentaco_enable_internal_endpoints * change the routes to be prefixed as internal/api/* and update comments * generated files * revert
1 parent e82a7a5 commit 263f8ac

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

taco/internal/api/internal.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515

1616

1717
func RegisterInternalRoutes(e *echo.Echo, deps Dependencies) {
18-
webhookSecret := os.Getenv("OPENTACO_WEBHOOK_SECRET")
18+
webhookSecret := os.Getenv("OPENTACO_ENABLE_INTERNAL_ENDPOINTS")
1919
if webhookSecret == "" {
20-
log.Println("OPENTACO_WEBHOOK_SECRET not configured, skipping internal routes")
20+
log.Println("OPENTACO_ENABLE_INTERNAL_ENDPOINTS not configured, skipping internal routes")
2121
return
2222
}
2323

@@ -33,7 +33,7 @@ func RegisterInternalRoutes(e *echo.Echo, deps Dependencies) {
3333
}
3434

3535
// Create internal group with webhook auth (with orgRepo for existence check)
36-
internal := e.Group("/internal")
36+
internal := e.Group("/internal/api")
3737
internal.Use(middleware.WebhookAuth(orgRepo))
3838

3939
// Organization and User management endpoints
@@ -51,8 +51,8 @@ func RegisterInternalRoutes(e *echo.Echo, deps Dependencies) {
5151
internal.GET("/users/:subject", orgHandler.GetUser)
5252
internal.GET("/users", orgHandler.ListUsers)
5353

54-
log.Println("Organization management endpoints registered at /internal/orgs")
55-
log.Println("User management endpoints registered at /internal/users")
54+
log.Println("Organization management endpoints registered at /internal/api/orgs")
55+
log.Println("User management endpoints registered at /internal/api/users")
5656
} else {
5757
log.Println("Warning: Could not create org/user repositories, endpoints disabled")
5858
}
@@ -67,7 +67,7 @@ func RegisterInternalRoutes(e *echo.Echo, deps Dependencies) {
6767
rbacGroup.GET("/permissions", rbacHandler.ListPermissions)
6868
rbacGroup.POST("/assign", rbacHandler.AssignRole)
6969
rbacGroup.POST("/revoke", rbacHandler.RevokeRole)
70-
log.Println("RBAC management endpoints registered at /internal/rbac")
70+
log.Println("RBAC management endpoints registered at /internal/api/rbac")
7171
}
7272

7373
orgService := domain.NewOrgService()
@@ -151,7 +151,7 @@ func RegisterInternalRoutes(e *echo.Echo, deps Dependencies) {
151151
return c.JSON(http.StatusOK, info)
152152
})
153153

154-
log.Printf("Internal routes registered at /internal/* with webhook authentication")
154+
log.Printf("Internal routes registered at /internal/api/* with webhook authentication")
155155
}
156156

157157
// wrapWithWebhookRBAC wraps a handler with RBAC permission checking

taco/internal/api/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,6 @@ func RegisterRoutes(e *echo.Echo, deps Dependencies) {
275275
})
276276
})
277277

278-
// Register webhook-authenticated internal routes (if OPENTACO_WEBHOOK_SECRET is set)
278+
// Register webhook-authenticated internal routes (if OPENTACO_ENABLE_INTERNAL_ENDPOINTS is set)
279279
RegisterInternalRoutes(e, deps)
280280
}

taco/internal/middleware/webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import (
2323
func WebhookAuth(orgRepo domain.OrganizationRepository) echo.MiddlewareFunc {
2424
return func(next echo.HandlerFunc) echo.HandlerFunc {
2525
return func(c echo.Context) error {
26-
webhookSecret := os.Getenv("OPENTACO_WEBHOOK_SECRET")
26+
webhookSecret := os.Getenv("OPENTACO_ENABLE_INTERNAL_ENDPOINTS")
2727

2828
// If no webhook secret is configured, deny access
2929
if webhookSecret == "" {
30-
slog.Error("Critical - webhook middleware called but OPENTACO_WEBHOOK_SECRET not configured")
30+
slog.Error("Critical - webhook middleware called but OPENTACO_ENABLE_INTERNAL_ENDPOINTS not configured")
3131
return c.JSON(http.StatusInternalServerError, map[string]string{
3232
"error": "webhook authentication not configured",
3333
})

0 commit comments

Comments
 (0)