Module: Mumukit::Auth::Protection

Included in:
Permissions
Defined in:
lib/mumukit/auth/protection.rb

Instance Method Summary collapse

Instance Method Details

#protect!(role, slug) ⇒ Object



2
3
4
5
# File 'lib/mumukit/auth/protection.rb', line 2

def protect!(role, slug)
  raise Mumukit::Auth::UnauthorizedAccessError,
        "Unauthorized access to #{slug} as #{role}. Scope is `#{scope_for role}`" unless has_permission?(role, slug)
end

#protect_delegation!(other) ⇒ Object



7
8
9
10
11
# File 'lib/mumukit/auth/protection.rb', line 7

def protect_delegation!(other)
  other ||= {}
  raise Mumukit::Auth::UnauthorizedAccessError,
        "Unauthorized delegation to #{other.to_h}" unless delegate_to?(Mumukit::Auth::Permissions.parse(other.to_h))
end