Commit 2f949489 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

start working at C version

parent 5046d211
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+3 −0
Original line number Diff line number Diff line
.idea
build
cmake-build-debug
+1 −0
Original line number Diff line number Diff line
build
 No newline at end of file
+20 −8
Original line number Diff line number Diff line
FROM ubuntu:22.04 AS no2fa
FROM ubuntu:22.04 AS package

RUN apt-get update && apt-get install -y ssh libpam-python  curl python2 sudo
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && python2 get-pip.py 
RUN pip2 config set global.target /lib/python2.7 && pip2 install requests
RUN apt-get update && apt-get install -y ssh cmake libpam0g-dev python3

COPY c  /src/c

WORKDIR /src/c
RUN bash ./build.sh



FROM package AS no2fa

RUN useradd test
RUN mkhomedir_helper test
RUN echo test:123 | chpasswd
RUN mkdir /run/sshd
RUN mkdir /run/sshd /etc/security/oidc

COPY oidc-pam.py  /etc/security/oidc/oidc-pam.py
COPY sshd /etc/pam.d/
COPY --from=package /src/c/build/*.deb  /

RUN dpkg -i /oidc-pam-0.1.0-Linux.deb

COPY c/sshd /etc/pam.d/
COPY sshd_pam.conf /etc/ssh/sshd_config.d/
COPY start_no2fa.sh  /tmp/oidc/
COPY update_oidc_config.py  /tmp/oidc/
@@ -28,7 +38,7 @@ CMD /tmp/oidc/start_no2fa.sh
FROM no2fa AS with2fa

RUN apt-get install -y libpam-google-authenticator
COPY sshd_2fa /etc/pam.d/sshd
COPY c/sshd_2fa /etc/pam.d/sshd

ENV OIDC_CHECK_2FA=1

@@ -39,3 +49,5 @@ CMD /tmp/oidc/start_2fa.sh


USER root

+41 −0
Original line number Diff line number Diff line
FROM ubuntu:22.04 AS no2fa

RUN apt-get update && apt-get install -y ssh libpam-python  curl python2 sudo
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && python2 get-pip.py 
RUN pip2 config set global.target /lib/python2.7 && pip2 install requests

RUN useradd test
RUN mkhomedir_helper test
RUN echo test:123 | chpasswd
RUN mkdir /run/sshd

COPY python/oidc-pam.py  /etc/security/oidc/oidc-pam.py
COPY python/sshd /etc/pam.d/
COPY sshd_pam.conf /etc/ssh/sshd_config.d/
COPY start_no2fa.sh  /tmp/oidc/
COPY update_oidc_config.py  /tmp/oidc/
COPY oidc-pam.json  /tmp/oidc/


EXPOSE 22

RUN chmod 777 /tmp/oidc/start_no2fa.sh
CMD /tmp/oidc/start_no2fa.sh


#2FA

FROM no2fa AS with2fa

RUN apt-get install -y libpam-google-authenticator
COPY python/sshd_2fa /etc/pam.d/sshd

ENV OIDC_CHECK_2FA=1

COPY start_2fa.sh  /tmp/oidc/
RUN chmod 777 /tmp/oidc/start_2fa.sh

CMD /tmp/oidc/start_2fa.sh


USER root
+29 −0
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.5)
project(oidc-pam LANGUAGES C)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")


find_package(PAM REQUIRED)

include_directories (
   ${PAM_INCLUDE_DIR}
)

add_library(oidc-pam SHARED oidc-pam.c config.c json/cJSON.c)
set_target_properties(oidc-pam PROPERTIES PREFIX "")

target_link_libraries(oidc-pam ${PAM_LIBRARIES})

install(TARGETS oidc-pam DESTINATION /usr/lib/security)

SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "ORNL") #required
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
INCLUDE(CPack)


add_executable(oidc-pam-main main.c config.c  json/cJSON.c)
target_link_libraries(oidc-pam-main ${PAM_LIBRARIES})
Loading