From e64242869d0e1038c44ab6e10b80dc9af9bc222f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Thu, 27 Jun 2024 11:16:03 +0000 Subject: [PATCH] chore: add authz controller --- ctrl.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ctrl.go diff --git a/ctrl.go b/ctrl.go new file mode 100644 index 0000000..63211b5 --- /dev/null +++ b/ctrl.go @@ -0,0 +1,24 @@ +package authz + +import "github.com/gofiber/fiber/v2" + +// AuthzController is the controller that holds the authz checker. +type AuthzController interface { + // Resolve is the resolver. + Resolve(ctx *fiber.Ctx) (AuthzPrincipal, AuthzObject, AuthzAction, error) +} + +var _ AuthzController = (*DefaultAuthzController)(nil) + +// DefaultAuthzController is the default implementation of the AuthzController. +type DefaultAuthzController struct{} + +// NewDefaultAuthzController returns a new DefaultAuthzController. +func NewDefaultAuthzController() *DefaultAuthzController { + return &DefaultAuthzController{} +} + +// ResolvePrincipal is the principal resolver. +func (d *DefaultAuthzController) Resolve(ctx *fiber.Ctx) (AuthzPrincipal, AuthzObject, AuthzAction, error) { + return AuthzNoPrincipial, AuthzNoObject, AuthzNoAction, nil +}