Class: Yes::Core::Authorization::CommandAuthorizer Abstract

Inherits:
Object
  • Object
show all
Extended by:
OpenTelemetry::Trackable
Includes:
OpenTelemetry::Trackable
Defined in:
lib/yes/core/authorization/command_authorizer.rb

Overview

This class is abstract.

command authorizer base class. Subclass and override call method to implement

a custom authorizer.

Direct Known Subclasses

CommandCerbosAuthorizer

Constant Summary collapse

CommandNotAuthorized =
Class.new(Yes::Core::Error)

Class Method Summary collapse

Class Method Details

.call(_command, auth_data) ⇒ Boolean

Implement this method to authorize a command. Needs to return true if command is authorized, otherwise raise CommandNotAuthorized.

Parameters:

  • command (Yes::Core::Command)

    command to authorize

  • auth_data (Hash)

    authorization data

Returns:

  • (Boolean)

    true if command is authorized

Raises:



21
22
23
24
25
26
# File 'lib/yes/core/authorization/command_authorizer.rb', line 21

def call(_command, auth_data)
  return true if super_admin?(auth_data)

  current_span&.status = ::OpenTelemetry::Trace::Status.error('Command not authorized')
  raise CommandNotAuthorized
end