Skip to content

Commit

Permalink
Add DEFAULT_WEBSITE and PROTECTION env var
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Apr 8, 2024
1 parent 7d7a761 commit 92dce58
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
VERSION: 2.18.2
PGVERSION: 15
DEBIANRELEASE: bookworm
DOCKERREVISION: 7
DOCKERREVISION: 8

on:
push:
Expand Down
3 changes: 2 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* 2024-04-08: add `DEFAULT_WEBSITE` and `PROTECTION` env var
* 2024-04-04: add docker revision in version string
* 2024-04-03: fix cache patch
* 2024-03-27: add missing Jitsi/logout method
Expand All @@ -9,7 +10,7 @@
* 2024-03-03: Add Jitsi support
* 2024-02-19: OIDC Auth PKCE
* 2024-02-12: 2.18.2
* 2024-01-31: Add SERVERNAME
* 2024-01-31: Add `SERVERNAME`
* 2024-01-11: Add patch to provide applications scope
* 2024-01-11: Add patch to fix OIDC logout when any relyong party failed
* 2024-01-08: Add fix-dropcsp.patch
Expand Down
9 changes: 8 additions & 1 deletion base-no-s6/install/etc/cont-init.d/update-llng-conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if test "$USERLOGGER" = "stderr"; then
perl -i -ne 'print unless /^userLogger\s*=/;print "userLogger = Lemonldap::NG::Common::Logger::Std\n" if/^\[\s*all\s*\]/;' /etc/lemonldap-ng/lemonldap-ng.ini;
fi

if test "$DEFAULT_WEBSITE" = "yes"; then
echo "Drop Nginx default website"
rm -f /etc/nginx/sites-enabled/default
fi

# OPTIONAL DATABASE FOR CONFIGURATION
#
# 1 - Check for PostgreSQL server
Expand Down Expand Up @@ -83,8 +88,10 @@ elif [ "$LDAP_URL" != "" ]; then
fi
fi

PORTALURL=`portalUrl "$PORTAL"`

/usr/share/docker-llng/updateConf "setDomain" "$SSODOMAIN"
/usr/share/docker-llng/updateConf "set" portal "$PORTAL"
/usr/share/docker-llng/updateConf "set" portal "$PORTALURL"

if test "$CROWDSEC_SERVER" != ""; then
echo "Configure LLNG to use $CROWDSEC_SERVER as Crowdsec server"
Expand Down
1 change: 1 addition & 0 deletions base-no-s6/install/usr/bin/portalHost
14 changes: 14 additions & 0 deletions base-no-s6/install/usr/bin/portalUrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/perl

use strict;

my $arg = $ARGV[0] or die 'Missing arg';
my $wantUrl = ($0 =~ /url/i);
my $prefix = 'https://';

$prefix = $1 if $arg =~ s#^(https?://)##;

$arg =~ s#/.*$##;
warn 'Maybe bas PORTAL value' unless $arg =~ /^\w[\w\.-]*\w$/;

print $wantUrl ? "$prefix$arg/" : $arg;
1 change: 1 addition & 0 deletions base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ENV SSODOMAIN=example.com \
PORTAL_CRON=yes \
FORCE_KEY_REGENERATION=no \
DEBIAN_FRONTEND=noninteractive \
DEFAULT_WEBSITE=no \
PGSSLCERT=/tmp/postgres.crt

COPY *.patch /
Expand Down
9 changes: 8 additions & 1 deletion base/install/etc/cont-init.d/update-llng-conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if test "$USERLOGGER" = "stderr"; then
perl -i -ne 'print unless /^userLogger\s*=/;print "userLogger = Lemonldap::NG::Common::Logger::Std\n" if/^\[\s*all\s*\]/;' /etc/lemonldap-ng/lemonldap-ng.ini;
fi

if test "$DEFAULT_WEBSITE" = "yes"; then
echo "Drop Nginx default website"
rm -f /etc/nginx/sites-enabled/default
fi

# OPTIONAL DATABASE FOR CONFIGURATION
#
# 1 - Check for PostgreSQL server
Expand Down Expand Up @@ -83,8 +88,10 @@ elif [ "$LDAP_URL" != "" ]; then
fi
fi

PORTALURL=`portalUrl "$PORTAL"`

/usr/share/docker-llng/updateConf "setDomain" "$SSODOMAIN"
/usr/share/docker-llng/updateConf "set" portal "$PORTAL"
/usr/share/docker-llng/updateConf "set" portal "$PORTALURL"

if test "$CROWDSEC_SERVER" != ""; then
echo "Configure LLNG to use $CROWDSEC_SERVER as Crowdsec server"
Expand Down
1 change: 1 addition & 0 deletions base/install/usr/bin/portalHost
14 changes: 14 additions & 0 deletions base/install/usr/bin/portalUrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/perl

use strict;

my $arg = $ARGV[0] or die 'Missing arg';
my $wantUrl = ($0 =~ /url/i);
my $prefix = 'https://';

$prefix = $1 if $arg =~ s#^(https?://)##;

$arg =~ s#/.*$##;
warn 'Maybe bas PORTAL value' unless $arg =~ /^\w[\w\.-]*\w$/;

print $wantUrl ? "$prefix$arg/" : $arg;
2 changes: 2 additions & 0 deletions full/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LABEL maintainer="Yadd [email protected]>" \
name="yadd/lemonldap-ng-full" \
version="v1.0"

ENV PROTECTION=manager

RUN echo "# Install nginx and portal and manager libs" && \
apt -y update && \
apt -y dist-upgrade && \
Expand Down
6 changes: 6 additions & 0 deletions full/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ docker-compose example to see how to do this using redis and

See [yadd/lemonldap-ng-base](https://github.com/guimard/llng-docker/blob/master/base/README.md#readme)

* Other:
* `DEFAULT_WEBSITE` = `no`, if set to `yes` the default Nginx website is
deleted
* `PROTECTION` = `manager`, set it to `none` if you don't want to protect
the manager by LemonLDAP-NG itself

## Docker-compose example

Example with Crowdsec enabled, Postgres database and Redis to share sessions.
Expand Down
15 changes: 14 additions & 1 deletion full/install/etc/cont-init.d/update-nginx-conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/command/with-contenv sh

PORTAL=${PORTAL:-auth.example.com}
PORTALHOST=`portalHost "$PORTAL"`
SSODOMAIN=${SSODOMAIN:-example.com}
SERVERNAME=${SERVERNAME:-${PORTALHOST}}
SERVERNAME=${SERVERNAME%/*}
export SERVERNAME

perl -i -pe 's#__FASTCGISOCKDIR__#/run/llng-fastcgi-server#g;
s#__PORT__#80#g;
s#__SERVERNAME__#$ENV{SERVERNAME}#g;
s#__DNSDOMAIN__#$ENV{SSODOMAIN}#g;
s#__PORTALSITEDIR__#/usr/share/lemonldap-ng/portal/htdocs/#g;
s#__PORTALSTATICDIR__#/usr/share/lemonldap-ng/portal/htdocs/static/#g;
Expand All @@ -12,5 +20,10 @@ s#__PORT__#80#g;
s#__DNSDOMAIN__#$ENV{SSODOMAIN}#g;
s#__MANAGERSITEDIR__#/usr/share/lemonldap-ng/manager/htdocs/#g;
s#__MANAGERSTATICDIR__#/usr/share/lemonldap-ng/manager/htdocs/static/#g;
s#__DEFDOCDIR__#/usr/share/doc/lemonldap-ng-doc/#g;
s#__DEFDOCDIR__#/usr/share/doc/lemonldap-ng/#g;
' /etc/lemonldap-ng/manager-nginx.conf

if test "$PROTECTION" != ""; then
echo "Set manager protection to $PROTECTION"
perl -i -pe 's/^protection\s*=.*$/protection='$PROTECTION'/' /etc/lemonldap-ng/lemonldap-ng.ini
fi
1 change: 1 addition & 0 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ LABEL maintainer="Yadd [email protected]>" \
name="yadd/lemonldap-ng-manager" \
version="v1.0"

ENV PROTECTION=manager

RUN echo "# Install nginx and manager libs" && \
apt -y update && \
Expand Down
6 changes: 6 additions & 0 deletions manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ docker-compose example to see how to do this using redis and

See [yadd/lemonldap-ng-base](https://github.com/guimard/llng-docker/blob/master/base/README.md#readme)

* Other:
* `DEFAULT_WEBSITE` = `no`, if set to `yes` the default Nginx website is
deleted
* `PROTECTION` = `manager`, set it to `none` if you don't want to protect
the manager by LemonLDAP-NG itself

## Docker-compose example

Example with Crowdsec enabled, Postgres database and Redis to share sessions.
Expand Down
5 changes: 5 additions & 0 deletions manager/install/etc/cont-init.d/update-nginx-manager-conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ s#__MANAGERSITEDIR__#/usr/share/lemonldap-ng/manager/htdocs/#g;
s#__MANAGERSTATICDIR__#/usr/share/lemonldap-ng/manager/htdocs/static/#g;
s#__DEFDOCDIR__#/usr/share/doc/lemonldap-ng/#g;
' /etc/lemonldap-ng/manager-nginx.conf

if test "$PROTECTION" != ""; then
echo "Set manager protection to $PROTECTION"
perl -i -pe 's/^protection\s*=.*$/protection='$PROTECTION'/' /etc/lemonldap-ng/lemonldap-ng.ini
fi
3 changes: 2 additions & 1 deletion portal/install/etc/cont-init.d/update-nginx-portal-conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/command/with-contenv sh

PORTAL=${PORTAL:-auth.example.com}
PORTALHOST=`portalHost "$PORTAL"`
SSODOMAIN=${SSODOMAIN:-example.com}
SERVERNAME=${SERVERNAME:-${PORTAL#*://}}
SERVERNAME=${SERVERNAME:-${PORTALHOST}}
SERVERNAME=${SERVERNAME%/*}
export SERVERNAME

Expand Down

0 comments on commit 92dce58

Please sign in to comment.