core/rails/app/controllers/application_controller.rb
#return true if we digest signed in
return true if we digest signed in
return true if we digest signed in
def rebar_auth
    Rails.logger.debug("username header: #{request.headers["HTTP_X_AUTHENTICATED_USERNAME"]}")
    Rails.logger.debug("capability header: #{request.headers["HTTP_X_AUTHENTICATED_CAPABILITY"]}")
    case
    when !request.headers["HTTP_X_AUTHENTICATED_USERNAME"].nil?
      unless request.headers["puma.socket"].peercert ||
             request.local? ||
             (/^::ffff:127\.0\.0\.1$/ =~ request.remote_ip)
        raise RebarForbiddenError.new("forbidden",User)
      end
      username = request.headers["HTTP_X_AUTHENTICATED_USERNAME"].strip
      @current_user = User.find_by(username: username)
      session[:digest_user] = username
      true
    when current_user
      val = authenticate_user!
      @current_user = current_user if val
      raise RebarForbiddenError.new("forbidden",User) if @current_user.system
      val
    when digest_request?
      digest_auth!
    when request.path == '/api/license'
      true  
    when (request.local? ||
          (/^::ffff:127\.0\.0\.1$/ =~ request.remote_ip)) &&
        File.exists?("/tmp/.rebar_in_bootstrap") &&
        (File.stat("/tmp/.rebar_in_bootstrap").uid == 0)
      @current_user = User.find_by(username: "SYSTEM")
      true
    else
      do_auth!
    end
    Rails.logger.info("Authenticated user: #{@current_user.username}") if @current_user
  end
def rebar_auth Rails . logger . debug ( "username header: #{request.headers["HTTP_X_AUTHENTICATED_USERNAME"]}" ) Rails . logger . debug ( "capability header: #{request.headers["HTTP_X_AUTHENTICATED_CAPABILITY"]}" ) case when ! request . headers [ "HTTP_X_AUTHENTICATED_USERNAME" ] . nil? unless request . headers [ "puma.socket" ] . peercert || request . local? || ( / ^::ffff:127 \. 0 \. 0 \. 1$ / =~ request . remote_ip ) raise RebarForbiddenError . new ( "forbidden" , User ) end username = request . headers [ "HTTP_X_AUTHENTICATED_USERNAME" ] . strip @current_user = User . find_by ( username : username ) session [ :digest_user ] = username true when current_user val = authenticate_user! @current_user = current_user if val raise RebarForbiddenError . new ( "forbidden" , User ) if @current_user . system val when digest_request? digest_auth! when request . path == '/api/license' true when ( request . local? || ( / ^::ffff:127 \. 0 \. 0 \. 1$ / =~ request . remote_ip ) ) && File . exists? ( "/tmp/.rebar_in_bootstrap" ) && ( File . stat ( "/tmp/.rebar_in_bootstrap" ) . uid == 0 ) @current_user = User . find_by ( username : "SYSTEM" ) true else do_auth! end Rails . logger . info ( "Authenticated user: #{@current_user.username}" ) if @current_user end
return true if we digest signed in
return true if we digest signed in
#Rails.logger.debug("peercert: #{request.headers["puma.socket"].peercert}") # specialized path for license & URL validation