Sha256: c7989259dafab6e6f1557bf0cc64df6032d95d2aa629b1e5e07a323b70b333ce

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

class KeyPairsController < ApplicationController
  include Authable::Rails::AuthableController
  include Authable::Rails::AuthableCRUD

  before_filter :find_key_pair, only: [ :show, :encrypt, :decrypt ]
  
  def create
    create_record do
      new_record whitelist: [ :id ]
    end
  end
  
  # Permissions checking is gated by access to the public key.
  def encrypt
    value = request.body.read
    render text: @key_pair.encrypt(value)
  end
  
  # Permissions checking is gated by access to the private key.
  def decrypt
    value = request.body.read
    render text: @key_pair.decrypt(value)
  end
  
  protected
  
  def find_key_pair
    @key_pair = KeyPair[params[:id]] or raise RecordNotFound
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-key-pair-0.2.1 app/controllers/key_pairs_controller.rb