-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Gavin Rogers edited this page Feb 28, 2014
·
3 revisions
Welcome to the dotfiles wiki!
* 5b00ff2 - (77 minutes ago) Add convenience file for restarting server. - Justin Rowles (HEAD, origin/master, origin/HEAD, master)
* 6ae4b89 - (78 minutes ago) Added basic test data. - Justin Rowles
* f7fdbee - (80 minutes ago) Added many tests. - Justin Rowles
* f90c15a - (21 hours ago) Server: Add constructor which will eventually read the config - Neil Houston
* 3b37e38 - (21 hours ago) Git Client Init: Remove extra super - Neil Houston
* 4355dbc - (21 hours ago) Adding tests for server and git_client - Justin Rowles
* da2a250 - (22 hours ago) Messed up merge. Fixed. - Justin Rowles
* 1ef7de5 - (23 hours ago) Merge branch 'master' of https://github.com/houst0n/hieracrypta - Justin Rowles
|\
| * fa18a84 - (2 days ago) Vagrant: Add vagrant machine for running tests - Neil Houston
| * f25e62a - (2 days ago) Gemspec: Remove redundant entries - Neil Houston
| * 7792070 - (2 days ago) Server: Do not need to set run as false anymore - Neil Houston
| * 7de6d68 - (2 days ago) JSON Data: Signed by HieraCrypta@Dev.Null - Neil Houston
| * 6f4edd1 - (2 days ago) Client Keys - Neil Houston
| * 43f8860 - (2 days ago) Fix typo in EncryptedData tests - Neil Houston
* | fbd0114 - (23 hours ago) Adding mappings and git client. Removed 'hello world'. - Justin Rowles
|/
* 33fccea - (2 days ago) Refactoring for clarity of tests. - Justin Rowles
require 'sinatra'
module Hieracrypta
class WebService < Sinatra::Base
configure do
set :run, false
end
def initialize
super
# This should read the configuration file; for now we'll hardcode:
repository_location = '~/hieracrypta'
# @git_client = Hieracrypta::GitClient.new(repository_location)
puts 'started'
end
get '/' do
'hello world'
end
####PUT /identities/ + body comprising a signed json object
#If the request is well formed and signed
#* HTTP 200
#If the request body is not well formed
#* HTTP 400 + body describing error reason
#If the request body is not signed by a known administrator
#* HTTP 403 + body describing error reason
put '/identities/' do
gpg_signature_client = Hieracrypta::EncryptedData.new(request.body)
if ! gpg_signature_client.trust_sig?
response.status=403
return 'This signature is not trusted'
end
'Signature trusted'
end
####GET /file/{identity}/branches/{branch}/{file}
#If the identity, branch, and file are known and the branch is allowed
#* HTTP 200 + body comprising encrypted file
#If the identity, branch, and file are known but the branch is not allowed
#* HTTP 403 + body describing error reason
#If the identity, branch or file are not known
#* HTTP 404 + body describing error reason
get '/file/:identity/branches/:branch/*' do
file = params[:splat][0]
identity=params[:identity]
branch=params[:branch]
content = @git_client.get_branch(branch, file)
send(content, identity)
end
####GET /file/{identity}/tags/{tag}/{file}
#If the identity, tag, and file are known and the tag is allowed
#* HTTP 200 + body comprising encrypted file
#If the identity, tag, and file are known but the tag is not allowed
#* HTTP 403 + body describing error reason
#If the identity, tag or file are not known
#* HTTP 404 + body describing error reason
get '/file/:identity/tags/:tag/*' do
file = params[:splat][0]
identity=params[:identity]
tag=params[:tag]
content = @git_client.get_tag(tag, file)
send(content, identity)
end
def send(content, identity)
gpg_encrypter_client = Hieracrypta::UnencryptedData.new(identity, content)
if (!gpg_encrypter_client.known?) then
response.status=404
return "No key found for identity '#{identity}'"
end
gpg_encrypter_client.encrypt
end
end
end