Module: Scimitar::Rbac::RouteHelper
- Defined in:
- lib/scimitar/rbac/route_helper.rb
Overview
Provides a convenience method for mounting RBAC SCIM resource routes in a Rails application’s routes.rb.
Usage:
# config/routes.rb
Rails.application.routes.draw do
namespace :scim_v2, path: "scim/v2" do
mount Scimitar::Engine, at: "/"
# Mount standard SCIM resources (Users, Groups) manually...
# Mount all RBAC resources at once:
Scimitar::Rbac::RouteHelper.mount_rbac_routes(self,
roles_controller: "scim_v2/roles",
entitlements_controller: "scim_v2/entitlements",
applications_controller: "scim_v2/applications"
)
end
end
Class Method Summary collapse
-
.mount_rbac_routes(router, **options) ⇒ Object
Mount CRUD routes for all RBAC resources.
-
.mount_resource_routes(router, resource_name, controller) ⇒ Object
Mount standard SCIM CRUD routes for a single resource.
Class Method Details
.mount_rbac_routes(router, **options) ⇒ Object
Mount CRUD routes for all RBAC resources.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scimitar/rbac/route_helper.rb', line 34 def self.mount_rbac_routes(router, **) if [:roles_controller] mount_resource_routes(router, "Roles", [:roles_controller]) end if [:entitlements_controller] mount_resource_routes(router, "Entitlements", [:entitlements_controller]) end if [:applications_controller] mount_resource_routes(router, "Applications", [:applications_controller]) end end |
.mount_resource_routes(router, resource_name, controller) ⇒ Object
Mount standard SCIM CRUD routes for a single resource.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/scimitar/rbac/route_helper.rb', line 53 def self.mount_resource_routes(router, resource_name, controller) router.instance_exec do get resource_name, to: "#{controller}#index" get "#{resource_name}/:id", to: "#{controller}#show" post resource_name, to: "#{controller}#create" put "#{resource_name}/:id", to: "#{controller}#replace" patch "#{resource_name}/:id", to: "#{controller}#update" delete "#{resource_name}/:id", to: "#{controller}#destroy" end end |