Adding Active Directory authentication to RStudio Server Open Source edition

Have you installed the statistical R language and  RStudio Server in a corporare environment and you would like to authenticate users using Active Directory instead of local unix users and passwords?

It is easy, you just need to install libpam-krb5… 😉

Below a sample Dockerfile if you want to install RStudio Server in a Docker container…

FROM rocker/rstudio

RUN apt-get update
ADD krb5.conf /etc
RUN apt-get install -y krb5-config libpam-krb5
RUN apt-get install -y openjdk-8-jdk r-cran-rjava

#setup R configs
RUN echo “r <- getOption(‘repos’); r[‘CRAN’] <- ‘http://cran.us.r-project.org’; options(repos = r);” > ~/.Rprofile

#INSTALL LIBAIO1 & UNZIP (NEEDED FOR STRONG-ORACLE)
RUN apt-get update \
&& apt-get install -y libaio1 \
&& apt-get install -y build-essential \
&& apt-get install -y unzip \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*

#ADD ORACLE INSTANT CLIENT
RUN mkdir -p opt/oracle
ADD ./oracle/linux/ .

RUN unzip instantclient-basic-linux.x64-12.2.0.1.0.zip -d /opt/oracle \
&& unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /opt/oracle \
&& unzip instantclient-odbc-linux.x64-12.2.0.1.0-2.zip -d /opt/oracle \
&& unzip instantclient-jdbc-linux.x64-12.2.0.1.0.zip -d /opt/oracle \
&& mv /opt/oracle/instantclient_12_2 /opt/oracle/instantclient \
&& ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so \
&& ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so \
&& rm instantclient-*zip

#ENV ORACLE_HOME=”/opt/oracle/instantclient”
ENV LD_LIBRARY_PATH=”/opt/oracle/instantclient”
#ENV OCI_HOME=”/opt/oracle/instantclient”
ENV OCI_LIB=”/opt/oracle/instantclient”
ENV OCI_INCLUDE_DIR=”/opt/oracle/instantclient/sdk/include”

RUN echo ‘/opt/oracle/instantclient/’ | tee -a /etc/ld.so.conf.d/oracle_instant_client.conf && ldconfig

RUN Rscript -e “install.packages(‘yhatr’)”
RUN Rscript -e “install.packages(‘ggplot2’)”
RUN Rscript -e “install.packages(‘plyr’)”
RUN Rscript -e “install.packages(‘reshape2’)”
RUN Rscript -e “install.packages(‘forecast’)”
RUN Rscript -e “install.packages(‘stringr’)”
RUN Rscript -e “install.packages(‘lubridate’)”
RUN Rscript -e “install.packages(‘randomForest’)”
RUN Rscript -e “install.packages(‘rpart’)”
RUN Rscript -e “install.packages(‘RJDBC’)”
RUN Rscript -e “install.packages(‘ROracle’)”

RUN adduser -u 2000 –disabled-password –gecos “” matteo
RUN adduser -u 2001 –disabled-password –gecos “” marco