Skip to content

Commit

Permalink
disable authorization feature added
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantprateek committed Jul 12, 2024
1 parent 65fcd0d commit bbeb793
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cyclops-ctrl/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DISABLE_TELEMETRY=true
PORT=8888
CERBOS_URL='localhost:3593'
CERBOS_URL='localhost:3593'
ENABLE_AUTHORIZATION='false'
3 changes: 3 additions & 0 deletions cyclops-ctrl/internal/controller/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ func getTargetGeneration(generation string, module *v1alpha1.Module) (*v1alpha1.
}

func (m *Modules) checkPermission(ctx *gin.Context, kind, resourceName, action string) bool {
if os.Getenv("ENABLE_AUTHORIZATION") == "false" {
return true
}
resource := cerbosSDK.NewResource(kind, "new").
WithAttr("name", resourceName).
WithAttr("action", action)
Expand Down
5 changes: 4 additions & 1 deletion cyclops-ctrl/internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handler

import (
"net/http"
"os"

"github.com/gin-gonic/gin"

Expand Down Expand Up @@ -59,7 +60,9 @@ func (h *Handler) Start() error {
// authentication
h.router.POST("/login", cerbos.Login(h.cerbosClient))

h.router.Use(cerbos.AuthMiddleware(h.cerbosClient))
if os.Getenv("ENABLE_AUTHORIZATION") == "true" {
h.router.Use(cerbos.AuthMiddleware(h.cerbosClient))
}

// templates
h.router.GET("/templates", templatesController.GetTemplate)
Expand Down

0 comments on commit bbeb793

Please sign in to comment.