Check client certificate CN in REPP

This commit is contained in:
Martin Lensment 2015-03-25 14:17:02 +02:00
parent b8e4b3ed87
commit 67196217a8

View file

@ -7,6 +7,14 @@ module Repp
@current_user ||= ApiUser.find_by(username: username, password: password) @current_user ||= ApiUser.find_by(username: username, password: password)
end end
before do
if request.ip == ENV['webclient_ip']
error! 'Certificate mismatch', 401 if env['HTTP_SSL_CLIENT_S_DN_CN'] != 'webclient'
else
error! 'Certificate mismatch', 401 if env['HTTP_SSL_CLIENT_S_DN_CN'] != @current_user.username
end
end
helpers do helpers do
attr_reader :current_user attr_reader :current_user
end end