forked from baron/baron-sso
ReBAC 고도화 및 애플리케이션 관리 시스템 통합 구현
This commit is contained in:
@@ -101,7 +101,7 @@ func validateScope(method, path string, rawScopes string) bool {
|
||||
}
|
||||
|
||||
// 3. 테넌트 관리 관련 (tenant:*)
|
||||
if strings.Contains(path, "/admin/tenants") {
|
||||
if strings.Contains(path, "/admin/tenants") || strings.Contains(path, "/admin/relying-parties") {
|
||||
if method == fiber.MethodGet {
|
||||
return scopeMap["tenant:read"]
|
||||
}
|
||||
|
||||
@@ -18,16 +18,14 @@ type RBACConfig struct {
|
||||
// RequireKetoPermission enforces permissions using Ory Keto (ReBAC)
|
||||
func RequireKetoPermission(config RBACConfig, namespace, relation string) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
// Bypass if already authenticated via API Key
|
||||
if c.Locals("apiKeyName") != nil {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
profile, err := config.AuthHandler.GetEnrichedProfile(c)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "unauthorized"})
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "unauthorized (trace:rbac_keto)"})
|
||||
}
|
||||
|
||||
// Store profile in locals for further use in handlers
|
||||
c.Locals("user_profile", profile)
|
||||
|
||||
// Super Admin bypass
|
||||
if profile.Role == domain.RoleSuperAdmin {
|
||||
return c.Next()
|
||||
@@ -65,10 +63,13 @@ func RequireRole(config RBACConfig) fiber.Handler {
|
||||
profile, err := config.AuthHandler.GetEnrichedProfile(c)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "unauthorized: " + err.Error(),
|
||||
"error": "unauthorized (trace:rbac_role): " + err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
// Store profile in locals for further use in handlers
|
||||
c.Locals("user_profile", profile)
|
||||
|
||||
// Super Admin always has access
|
||||
if profile.Role == domain.RoleSuperAdmin {
|
||||
return c.Next()
|
||||
@@ -112,9 +113,12 @@ func RequireTenantMatch(config RBACConfig) fiber.Handler {
|
||||
|
||||
profile, err := config.AuthHandler.GetEnrichedProfile(c)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "unauthorized"})
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "unauthorized (trace:rbac_match)"})
|
||||
}
|
||||
|
||||
// Store profile in locals for further use in handlers
|
||||
c.Locals("user_profile", profile)
|
||||
|
||||
// Super Admin bypass
|
||||
if profile.Role == domain.RoleSuperAdmin {
|
||||
return c.Next()
|
||||
|
||||
Reference in New Issue
Block a user