mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
base64 dns key
This commit is contained in:
parent
4a02477300
commit
30f014f6a3
1 changed files with 4 additions and 5 deletions
|
@ -72,7 +72,6 @@ end
|
||||||
before path do
|
before path do
|
||||||
if params.has_key?("public_key")
|
if params.has_key?("public_key")
|
||||||
public_key = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
public_key = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
||||||
puts public_key
|
|
||||||
unless public_key.length == 24
|
unless public_key.length == 24
|
||||||
halt 400, { :error => "Key is invalid: #{public_key.to_s.encode('UTF-8', {:invalid => :replace, :undef => :replace, :replace => '?'})}" }.to_json
|
halt 400, { :error => "Key is invalid: #{public_key.to_s.encode('UTF-8', {:invalid => :replace, :undef => :replace, :replace => '?'})}" }.to_json
|
||||||
end
|
end
|
||||||
|
@ -111,7 +110,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
post '/key/:public_key' do
|
post '/key/:public_key' do
|
||||||
params[:public_key] = Base64.decode64(params[:public_key])
|
params[:public_key] = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
||||||
# Check params
|
# Check params
|
||||||
halt 400, { :error => "Please indicate a subdomain" }.to_json unless params.has_key?("subdomain")
|
halt 400, { :error => "Please indicate a subdomain" }.to_json unless params.has_key?("subdomain")
|
||||||
|
|
||||||
|
@ -134,7 +133,7 @@ post '/key/:public_key' do
|
||||||
end
|
end
|
||||||
|
|
||||||
put '/key/:public_key' do
|
put '/key/:public_key' do
|
||||||
params[:public_key] = Base64.decode64(params[:public_key])
|
params[:public_key] = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
||||||
entry = Entry.first(:public_key => params[:public_key])
|
entry = Entry.first(:public_key => params[:public_key])
|
||||||
unless request.ip == entry.current_ip
|
unless request.ip == entry.current_ip
|
||||||
entry.ips << Ip.create(:ip_addr => request.ip)
|
entry.ips << Ip.create(:ip_addr => request.ip)
|
||||||
|
@ -148,7 +147,7 @@ put '/key/:public_key' do
|
||||||
end
|
end
|
||||||
|
|
||||||
delete '/key/:public_key' do
|
delete '/key/:public_key' do
|
||||||
params[:public_key] = Base64.decode64(params[:public_key])
|
params[:public_key] = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
||||||
if entry = Entry.first(:public_key => params[:public_key])
|
if entry = Entry.first(:public_key => params[:public_key])
|
||||||
if entry.destroy
|
if entry.destroy
|
||||||
halt 200, "OK".to_json
|
halt 200, "OK".to_json
|
||||||
|
@ -179,7 +178,7 @@ get '/all/:domain' do
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/ips/:public_key' do
|
get '/ips/:public_key' do
|
||||||
params[:public_key] = Base64.decode64(params[:public_key])
|
params[:public_key] = Base64.decode64(params[:public_key].encode('ascii-8bit'))
|
||||||
unless ALLOWED_IP.include? request.ip
|
unless ALLOWED_IP.include? request.ip
|
||||||
status 403
|
status 403
|
||||||
return "Access denied"
|
return "Access denied"
|
||||||
|
|
Loading…
Reference in a new issue