From 0c82763a2d576339cbc8f8aa5f7bd2734a6d1079 Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Wed, 19 May 2021 13:30:35 +0200 Subject: [PATCH] B #~: fix login with ruby version <= 2.0.0 (#1230) Co-authored-by: Jorge Lobo --- src/sunstone/sunstone-server.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index a78611fc8c..b2c79011fd 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -543,8 +543,20 @@ helpers do session[:federation_mode] = active_zone_configuration['FEDERATION/MODE'].upcase session[:mode] = $conf[:mode] - auth = request.env['HTTP_AUTHORIZATION'].match(/(?\w+) (?\w+)/) - session[:auth] = auth[:pass] + if RUBY_VERSION > '2.0.0' + auth = request.env['HTTP_AUTHORIZATION'].match(/(?\w+) (?\w+)/) + session[:auth] = auth[:pass] + else + auth = request.env['HTTP_AUTHORIZATION'].split(" ") + if auth[0] && auth[0].downcase === 'basic' + session[:auth] = auth[1] + else + logger.info { 'Unauthorized login attempt' } + return [401, ''] + end + end + + #get firedge JWT session[:fireedge_token] = get_fireedge_token(two_factor_auth_token)