class OmfCommon::Auth::PDP::JobService

Authorise job service (experiment controller) messages

Public Class Methods

new(opts = {}) click to toggle source
# File lib/omf_common/auth/pdp/job_service.rb, line 7
def initialize(opts = {})
  @slice = opts[:slice]
end

Public Instance Methods

authorize(msg, &block) click to toggle source
# File lib/omf_common/auth/pdp/job_service.rb, line 11
def authorize(msg, &block)
  if msg.assert.nil?
    warn 'No assertion found, drop it'
    return nil
  end

  assert = OmfCommon::Auth::Assertion.new(msg.assert)

  unless assert.verify
    return nil
  else
    info "#{msg.src.address} tells >> #{assert.iss} says >> #{assert.content}"
  end

  # Check current slice with slice specified in assertion
  if assert.content =~ /(.+) can use slice (.+)/ &&
    $1 == msg.src.id.to_s &&
    $2 == @slice.to_s

    block.call(msg) if block
    return msg
  else
    warn 'Drop it'
    return nil
  end
end