Class: AdminSuite::AuthorizationContext
- Inherits:
-
Object
- Object
- AdminSuite::AuthorizationContext
- Defined in:
- lib/admin_suite/authorization_context.rb
Overview
Surface-agnostic context handed to config.authorize.
Replaces the old controller: keyword, which could not be honestly
populated for a non-HTTP surface. surface lets one hook express
different policy per entry point -- e.g. reads from anywhere, writes
only from the human UI.
Constant Summary collapse
- SURFACES =
%i[web mcp].freeze
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#surface ⇒ Object
readonly
Returns the value of attribute surface.
Instance Method Summary collapse
-
#initialize(surface:, controller: nil, request: nil) ⇒ AuthorizationContext
constructor
A new instance of AuthorizationContext.
- #mcp? ⇒ Boolean
- #web? ⇒ Boolean
Constructor Details
#initialize(surface:, controller: nil, request: nil) ⇒ AuthorizationContext
Returns a new instance of AuthorizationContext.
15 16 17 18 19 20 21 22 23 |
# File 'lib/admin_suite/authorization_context.rb', line 15 def initialize(surface:, controller: nil, request: nil) unless SURFACES.include?(surface) raise ArgumentError, "Unknown AdminSuite authorization surface #{surface.inspect}. Expected one of #{SURFACES.inspect}." end @surface = surface @controller = controller @request = request end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
13 14 15 |
# File 'lib/admin_suite/authorization_context.rb', line 13 def controller @controller end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
13 14 15 |
# File 'lib/admin_suite/authorization_context.rb', line 13 def request @request end |
#surface ⇒ Object (readonly)
Returns the value of attribute surface.
13 14 15 |
# File 'lib/admin_suite/authorization_context.rb', line 13 def surface @surface end |
Instance Method Details
#mcp? ⇒ Boolean
26 |
# File 'lib/admin_suite/authorization_context.rb', line 26 def mcp? = surface == :mcp |
#web? ⇒ Boolean
25 |
# File 'lib/admin_suite/authorization_context.rb', line 25 def web? = surface == :web |