RStudio when launched without Singularity is having strange troubles with authentication

@jeff.ohrstrom Thanks for the messages. I got it to work eventually.

In my case the error below was caused by a faulty singularity environment setup

Here is my working custom Lua module that sets up the singularity environment for OOD

help([[ rstudio - loads rstudio with singularity environment for ondemand apps ]])
whatis("loads rstudio with singularity environment for ondemand")
setenv("RSTUDIO_SERVER_IMAGE","/marisdata/COMMON/rserver-launcher-centos7.simg")
setenv("SINGULARITY_BINDPATH","/mnt,/opt,/srv,/usr,/marisdata,/home")
load("RStudio-Server/1.4.1717-foss-2021a-Java-11-R-4.1.0")
local ldcrap = os.getenv("LD_LIBRARY_PATH")
setenv("SINGULARITYENV_LD_LIBRARY_PATH",ldcrap)

Adding /etc to SINGULARITY_BINDPATH caused the observed connection error.

If it can be of any help for others still struggling to get it to work, I report below some other important app files

# cat template/script.sh.erb
#!/usr/bin/env bash

# Load the required environment
setup_env () {
  
  # as reported above
  module load RStudio-OOD-Container
}
setup_env

#
# Start RStudio Server
#

# PAM auth helper used by RStudio
export RSTUDIO_AUTH="${PWD}/bin/auth"

# These are needed for the logs in the OOD session dir
export RSTUDIO_LOG_CONF="${PWD}/etc"
mkdir -p "${PWD}/logs"
...

# needed for RStudio run files
mkdir -p "$TMPDIR/var/lib"

set -x
# Launch the RStudio Server
echo "Starting up rserver..."

singularity run -B "$TMPDIR:/tmp,$TMPDIR/var/lib:/var/lib/rstudio-server" \
 -B "$RSTUDIO_LOG_CONF:/etc/rstudio" \
 "$RSTUDIO_SERVER_IMAGE" \
 --www-port "${port}" \
 --auth-none 0 \
 --auth-pam-helper-path "${RSTUDIO_AUTH}" \
 --auth-encrypt-password 0 \
 --server-data-dir "$TMPDIR/rstudio-server" \
 --server-pid-file "$TMPDIR/rstudio-server/rstudio-server.pid" \
 --rsession-path "${RSESSION_WRAPPER_FILE}" \
 --server-user=$(whoami)

echo 'Singularity has exited...'

# cat submit.yml.erb
---
batch_connect:
  template: "basic"
  conn_params:
    - csrftoken
script:
...
# cat view.html.erb
<script type="text/javascript">
(function () {
    let d = new Date();
    d.setTime(d.getTime() + (7*24*60*60*1000));
    let expires = "expires="+ d.toUTCString();
    let cookie = `csrf-token=<%= csrftoken %>;${expires};path=/rnode/<%= host %>/<%= port %>/;SameSite=Strict;Secure;`
    document.cookie = cookie;
})();



</script>
<form action="/rnode/<%= host %>/<%= port %>/auth-do-sign-in" method="post" target="_blank">
  <input type="hidden" name="username" value="<%= ENV["USER"] %>">
  <input type="hidden" name="password" value="<%= password %>">
  <input type="hidden" name="staySignedIn" value="1">
  <input type="hidden" name="appUri" value="">
  <input id="csrfToken" type="hidden" name="csrf-token" value="<%= csrftoken %>"/>
  <button class="btn btn-primary" type="submit">
    <i class="fa fa-registered"></i> Connect to RStudio Server
  </button>
</form>

# cat template/before.sh.erb
# Export the module function if it exists
[[ $(type -t module) == "function" ]] && export -f module

# Find available port to run server on
port=$(find_port ${host})

# Define a password and export it for RStudio authentication
password="$(create_passwd 16)"
export RSTUDIO_PASSWORD="${password}"

# create CSRF token
<%-
  require 'securerandom'
  csrftoken=SecureRandom.uuid
-%>
export csrftoken="<%= csrftoken %>"

Finally template/bin/auth and template/etc/logging.conf.erb are as you already reported.