<commit_before>require 'sinatra/base'

require 'conjur/demo/sinatra'

class ServiceAccessControl < Sinatra::Base
  extend Conjur::Demo::Sinatra
  
  configure!
  
  helpers do
    def can?(privilege, resource)
      resource = @api.resource [ account, 'service', [ namespace, resource ].join('/') ].join(':')
      resource.permitted?(privilege)
    end
  end
  
  get '/fry/bacon' do
    halt(403) unless can?('fry', 'bacon')
    
    'Bacon fried!'
  end

  # start the server if ruby file executed directly
  run! if app_file == $0
end
<commit_msg>require authorization for all methods<commit_after>require 'sinatra/base'

require 'conjur/demo/sinatra'

class ServiceAccessControl < Sinatra::Base
  extend Conjur::Demo::Sinatra
  
  configure!

  before do
    parse_authorization
  end
  
  helpers do
    def can?(privilege, resource)
      resource = @api.resource [ account, 'service', [ namespace, resource ].join('/') ].join(':')
      resource.permitted?(privilege)
    end
  end
  
  get '/fry/bacon' do
    halt(403) unless can?('fry', 'bacon')
    
    'Bacon fried!'
  end

  # start the server if ruby file executed directly
  run! if app_file == $0
end

{'fraction_non_alphanumeric': 0.12318220701454234, 'fraction_numerical': 0.006843455945252352, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2660635', 'n_tokens_mistral': 408, 'n_tokens_neox': 391, 'n_words': 106}