diff --git a/.travis.yml b/.travis.yml index e333fe95..2a651415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: go required: sudo go: - - '1.13' + - "1.13" services: - docker @@ -19,25 +19,73 @@ addons: - libgif-dev - google-chrome-stable -install: # Install ChromeDriver (64bits; replace 64 with 32 for 32bits). - - wget -N https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip -P ~/ - - unzip ~/chromedriver_linux64.zip -d ~/ - - rm ~/chromedriver_linux64.zip - - sudo mv -f ~/chromedriver /usr/local/share/ - - sudo chmod +x /usr/local/share/chromedriver - - sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver +install: + - go mod download before_script: - export PATH=./cmd/authelia-scripts/:/tmp:$PATH - - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash - - nvm install v12 && nvm use v12 && npm i - source bootstrap.sh jobs: include: - - stage: test + - stage: build & test + before_script: + - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash + - nvm install v12 && nvm use v12 script: - authelia-scripts --log-level debug ci + + # Run all suites in a dedicated container + - &e2e-test + stage: end-to-end suite tests + env: + - SUITE_NAME=BypassAll + before_script: + # Install chrome driver + - wget -N https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip -P ~/ + - unzip ~/chromedriver_linux64.zip -d ~/ + - rm ~/chromedriver_linux64.zip + - sudo mv -f ~/chromedriver /usr/local/share/ + - sudo chmod +x /usr/local/share/chromedriver + - sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver + script: + # Run the suite + - CI=true authelia-scripts --log-level debug suites test $SUITE_NAME --headless + # TODO(c.michaud): check if all suites are listed based on `authelia-scripts suites list` command. + - <<: *e2e-test + env: + - SUITE_NAME=Docker + - <<: *e2e-test + env: + - SUITE_NAME=DuoPush + - <<: *e2e-test + env: + - SUITE_NAME=HighAvailability + - <<: *e2e-test + env: + - SUITE_NAME=Kubernetes + - <<: *e2e-test + env: + - SUITE_NAME=LDAP + - <<: *e2e-test + env: + - SUITE_NAME=Mariadb + - <<: *e2e-test + env: + - SUITE_NAME=NetworkACL + - <<: *e2e-test + env: + - SUITE_NAME=Postgres + - <<: *e2e-test + env: + - SUITE_NAME=ShortTimeouts + - <<: *e2e-test + env: + - SUITE_NAME=Standalone + - <<: *e2e-test + env: + - SUITE_NAME=Traefik + - &build-images stage: build images env: @@ -56,9 +104,9 @@ jobs: - tar -czf authelia-linux-$ARCH.tar.gz authelia-linux-$ARCH public_html deploy: provider: releases - api_key: '$GITHUB_API_KEY' + api_key: "$GITHUB_API_KEY" file_glob: true - file: 'authelia-linux-$ARCH.tar.gz' + file: "authelia-linux-$ARCH.tar.gz" skip_cleanup: true on: tags: true diff --git a/Dockerfile b/Dockerfile index 4f81f0d7..02a7554e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,14 @@ FROM golang:1.13-alpine AS builder-backend RUN apk --no-cache add gcc musl-dev WORKDIR /go/src/app -COPY . . + +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +COPY cmd cmd +COPY internal internal # CGO_ENABLED=1 is mandatory for building go-sqlite3 RUN cd cmd/authelia && GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -tags netgo -ldflags '-w' -o authelia @@ -16,10 +23,10 @@ RUN cd cmd/authelia && GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -tags netg # ======================================== # ===== Build image for the frontend ===== # ======================================== -FROM node:11-alpine AS builder-frontend +FROM node:12-alpine AS builder-frontend WORKDIR /node/src/app -COPY client . +COPY web . # Install the dependencies and build RUN npm ci && npm run build @@ -41,4 +48,4 @@ EXPOSE 9091 VOLUME /etc/authelia VOLUME /var/lib/authelia -CMD ["./authelia", "-config", "/etc/authelia/config.yml"] +CMD ["./authelia", "-config", "/etc/authelia/configuration.yml"] diff --git a/Dockerfile.arm32v7 b/Dockerfile.arm32v7 index 89660420..689c06fe 100644 --- a/Dockerfile.arm32v7 +++ b/Dockerfile.arm32v7 @@ -8,7 +8,14 @@ COPY ./qemu-arm-static /usr/bin/qemu-arm-static RUN apk --no-cache add gcc musl-dev WORKDIR /go/src/app -COPY . . + +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +COPY cmd cmd +COPY internal internal # CGO_ENABLED=1 is mandatory for building go-sqlite3 RUN cd cmd/authelia && GOOS=linux GOARCH=arm CGO_ENABLED=1 go build -tags netgo -ldflags '-w' -o authelia @@ -17,10 +24,10 @@ RUN cd cmd/authelia && GOOS=linux GOARCH=arm CGO_ENABLED=1 go build -tags netgo # ======================================== # ===== Build image for the frontend ===== # ======================================== -FROM node:11-alpine AS builder-frontend +FROM node:12-alpine AS builder-frontend WORKDIR /node/src/app -COPY client . +COPY web . # Install the dependencies and build RUN npm ci && npm run build @@ -45,4 +52,4 @@ EXPOSE 9091 VOLUME /etc/authelia VOLUME /var/lib/authelia -CMD ["./authelia", "-config", "/etc/authelia/config.yml"] +CMD ["./authelia", "-config", "/etc/authelia/configuration.yml"] diff --git a/Dockerfile.arm64v8 b/Dockerfile.arm64v8 index ca52b457..871a334a 100644 --- a/Dockerfile.arm64v8 +++ b/Dockerfile.arm64v8 @@ -8,7 +8,14 @@ COPY ./qemu-aarch64-static /usr/bin/qemu-aarch64-static RUN apk --no-cache add gcc musl-dev WORKDIR /go/src/app -COPY . . + +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +COPY cmd cmd +COPY internal internal # CGO_ENABLED=1 is mandatory for building go-sqlite3 RUN cd cmd/authelia && GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -tags netgo -ldflags '-w' -o authelia @@ -17,10 +24,10 @@ RUN cd cmd/authelia && GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -tags netg # ======================================== # ===== Build image for the frontend ===== # ======================================== -FROM node:11-alpine AS builder-frontend +FROM node:12-alpine AS builder-frontend WORKDIR /node/src/app -COPY client . +COPY web . # Install the dependencies and build RUN npm ci && npm run build @@ -45,4 +52,4 @@ EXPOSE 9091 VOLUME /etc/authelia VOLUME /var/lib/authelia -CMD ["./authelia", "-config", "/etc/authelia/config.yml"] +CMD ["./authelia", "-config", "/etc/authelia/configuration.yml"] diff --git a/bootstrap.sh b/bootstrap.sh index 3d69b3b8..7b92a0cc 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -7,6 +7,9 @@ if [ -z "$OLD_PS1" ]; then export PS1="(authelia) $PS1" fi +export USER_ID=$(id -u) +export GROUP_ID=$(id -g) + echo "[BOOTSTRAP] Checking if Go is installed..." if [ ! -x "$(command -v go)" ]; diff --git a/cmd/authelia-scripts/cmd_bootstrap.go b/cmd/authelia-scripts/cmd_bootstrap.go index d29e6006..8508d2fb 100644 --- a/cmd/authelia-scripts/cmd_bootstrap.go +++ b/cmd/authelia-scripts/cmd_bootstrap.go @@ -96,15 +96,6 @@ func shell(cmd string) { runCommand("bash", "-c", cmd) } -func buildHelperDockerImages() { - shell("docker build -t authelia-example-backend example/compose/nginx/backend") - shell("docker build -t authelia-duo-api example/compose/duo-api") - - shell("docker-compose -f docker-compose.yml -f example/compose/kind/docker-compose.yml build") - shell("docker-compose -f docker-compose.yml -f example/compose/authelia/docker-compose.backend.yml build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)") - shell("docker-compose -f docker-compose.yml -f example/compose/authelia/docker-compose.frontend.yml build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)") -} - func prepareHostsFile() { contentBytes, err := readHostsFile() @@ -209,9 +200,6 @@ func Bootstrap(cobraCmd *cobra.Command, args []string) { log.Fatal("GOPATH is not set") } - bootstrapPrintln("Building development Docker images...") - buildHelperDockerImages() - createTemporaryDirectory() bootstrapPrintln("Preparing /etc/hosts to serve subdomains of example.com...") diff --git a/cmd/authelia-scripts/cmd_build.go b/cmd/authelia-scripts/cmd_build.go index 9585d7b7..9d108859 100644 --- a/cmd/authelia-scripts/cmd_build.go +++ b/cmd/authelia-scripts/cmd_build.go @@ -24,7 +24,7 @@ func buildAutheliaBinary() { func buildFrontend() { // Install npm dependencies cmd := utils.CommandWithStdout("npm", "ci") - cmd.Dir = "client" + cmd.Dir = "web" if err := cmd.Run(); err != nil { log.Fatal(err) @@ -32,13 +32,13 @@ func buildFrontend() { // Then build the frontend cmd = utils.CommandWithStdout("npm", "run", "build") - cmd.Dir = "client" + cmd.Dir = "web" if err := cmd.Run(); err != nil { log.Fatal(err) } - if err := os.Rename("client/build", OutputDir+"/public_html"); err != nil { + if err := os.Rename("web/build", OutputDir+"/public_html"); err != nil { log.Fatal(err) } } diff --git a/cmd/authelia-scripts/cmd_ci.go b/cmd/authelia-scripts/cmd_ci.go index cfa3d6b4..16ea9d6f 100644 --- a/cmd/authelia-scripts/cmd_ci.go +++ b/cmd/authelia-scripts/cmd_ci.go @@ -18,18 +18,18 @@ const dockerPullCommandLine = "docker-compose -f docker-compose.yml " + // RunCI run the CI scripts func RunCI(cmd *cobra.Command, args []string) { - log.Info("=====> Build stage") + log.Info("=====> Build stage <=====") if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "build").Run(); err != nil { log.Fatal(err) } - log.Info("=====> Unit testing stage") + log.Info("=====> Unit testing stage <=====") if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "unittest").Run(); err != nil { log.Fatal(err) } - log.Info("=====> End-to-end testing stage") - if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "suites", "test", "--headless", "--only-forbidden").Run(); err != nil { + log.Info("=====> Build Docker stage <=====") + if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "docker", "build").Run(); err != nil { log.Fatal(err) } } diff --git a/cmd/authelia-scripts/cmd_suites.go b/cmd/authelia-scripts/cmd_suites.go index 93c4cd55..02e7d213 100644 --- a/cmd/authelia-scripts/cmd_suites.go +++ b/cmd/authelia-scripts/cmd_suites.go @@ -27,11 +27,9 @@ var ErrNoRunningSuite = errors.New("no running suite") var runningSuiteFile = ".suite" var headless bool -var onlyForbidden bool func init() { SuitesTestCmd.Flags().BoolVar(&headless, "headless", false, "Run tests in headless mode") - SuitesTestCmd.Flags().BoolVar(&onlyForbidden, "only-forbidden", false, "Mocha 'only' filters are forbidden") } // SuitesListCmd Command for listing the available suites @@ -79,17 +77,17 @@ var SuitesTeardownCmd = &cobra.Command{ runningSuite, err := getRunningSuite() if err != nil { - panic(err) + log.Fatal(err) } if runningSuite == "" { - panic(ErrNoRunningSuite) + log.Fatal(ErrNoRunningSuite) } suiteName = runningSuite } if err := teardownSuite(suiteName); err != nil { - panic(err) + log.Fatal(err) } }, Args: cobra.MaximumNArgs(1), @@ -143,6 +141,14 @@ func runSuiteSetupTeardown(command string, suite string) error { return utils.RunCommandWithTimeout(cmd, s.SetUpTimeout) } +func runOnSetupTimeout(suite string) error { + cmd := utils.CommandWithStdout("go", "run", "cmd/authelia-suites/main.go", "timeout", suite) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Env = os.Environ() + return utils.RunCommandWithTimeout(cmd, 15*time.Second) +} + func setupSuite(suiteName string) error { log.Infof("Setup environment for suite %s...", suiteName) signalChannel := make(chan os.Signal) @@ -156,10 +162,10 @@ func setupSuite(suiteName string) error { }() if errSetup := runSuiteSetupTeardown("setup", suiteName); errSetup != nil || interrupted { - err := teardownSuite(suiteName) - if err != nil { - log.Error(err) + if errSetup == utils.ErrTimeoutReached { + runOnSetupTimeout(suiteName) } + teardownSuite(suiteName) return errSetup } @@ -231,7 +237,7 @@ func runSuiteTests(suiteName string, withEnv bool) error { if suite.TestTimeout > 0 { timeout = fmt.Sprintf("%ds", int64(suite.TestTimeout/time.Second)) } - testCmdLine := fmt.Sprintf("go test ./internal/suites -timeout %s -run '^(Test%sSuite)$'", timeout, suiteName) + testCmdLine := fmt.Sprintf("go test -v ./internal/suites -timeout %s -run '^(Test%sSuite)$'", timeout, suiteName) log.Infof("Running tests of suite %s...", suiteName) log.Debugf("Running tests with command: %s", testCmdLine) diff --git a/cmd/authelia-suites/main.go b/cmd/authelia-suites/main.go index d951daf0..ddd473e0 100644 --- a/cmd/authelia-suites/main.go +++ b/cmd/authelia-suites/main.go @@ -32,6 +32,12 @@ func main() { Run: setupSuite, } + setupTimeoutCmd := &cobra.Command{ + Use: "timeout [suite]", + Short: "Run the OnSetupTimeout callback when setup times out", + Run: setupTimeoutSuite, + } + stopCmd := &cobra.Command{ Use: "teardown [suite]", Short: "Teardown the suite environment", @@ -39,6 +45,7 @@ func main() { } rootCmd.AddCommand(startCmd) + rootCmd.AddCommand(setupTimeoutCmd) rootCmd.AddCommand(stopCmd) rootCmd.Execute() } @@ -101,6 +108,18 @@ func setupSuite(cmd *cobra.Command, args []string) { log.Info("Environment is ready!") } +func setupTimeoutSuite(cmd *cobra.Command, args []string) { + suiteName := args[0] + s := suites.GlobalRegistry.Get(suiteName) + + if s.OnSetupTimeout == nil { + return + } + if err := s.OnSetupTimeout(); err != nil { + log.Fatal(err) + } +} + func teardownSuite(cmd *cobra.Command, args []string) { if os.Getenv("SKIP_TEARDOWN") != "" { return diff --git a/config.template.yml b/config.template.yml index ce43491a..74ec4dfe 100644 --- a/config.template.yml +++ b/config.template.yml @@ -99,7 +99,6 @@ authentication_backend: ## file: ## path: ./users_database.yml - # Access Control # # Access control is a list of rules defining the authorizations applied for one @@ -156,47 +155,45 @@ access_control: - domain: singlefactor.example.com policy: one_factor - # Rules applied to 'admin' group - - domain: 'mx2.mail.example.com' - subject: 'group:admin' + # Rules applied to 'admins' group + - domain: "mx2.mail.example.com" + subject: "groups:admins" policy: deny - - domain: '*.example.com' - subject: 'group:admin' + - domain: "*.example.com" + subject: "groups:admins" policy: two_factor # Rules applied to 'dev' group - domain: dev.example.com resources: - - '^/groups/dev/.*$' - subject: 'group:dev' + - "^/groups/dev/.*$" + subject: "group:dev" policy: two_factor # Rules applied to user 'john' - domain: dev.example.com resources: - - '^/users/john/.*$' - subject: 'user:john' + - "^/users/john/.*$" + subject: "user:john" policy: two_factor - # Rules applied to user 'harry' - domain: dev.example.com resources: - - '^/users/harry/.*$' - subject: 'user:harry' + - "^/users/harry/.*$" + subject: "user:harry" policy: two_factor # Rules applied to user 'bob' - - domain: '*.mail.example.com' - subject: 'user:bob' + - domain: "*.mail.example.com" + subject: "user:bob" policy: two_factor - - domain: 'dev.example.com' + - domain: "dev.example.com" resources: - - '^/users/bob/.*$' - subject: 'user:bob' + - "^/users/bob/.*$" + subject: "user:bob" policy: two_factor - # Configuration of session cookies # # The session cookies identify the user once logged in. @@ -283,7 +280,6 @@ notifier: host: 127.0.0.1 port: 1025 sender: admin@example.com - # Sending an email using a Gmail account is as simple as the next section. # You need to create an app password by following: https://support.google.com/accounts/answer/185833?hl=en ## smtp: diff --git a/example/compose/authelia/Dockerfile.backend b/example/compose/authelia/Dockerfile.backend index bfb7659a..5847101b 100644 --- a/example/compose/authelia/Dockerfile.backend +++ b/example/compose/authelia/Dockerfile.backend @@ -1,8 +1,10 @@ -FROM golang:1.13-stretch +FROM golang:1.13-alpine + +RUN apk --no-cache add gcc musl-dev ARG USER_ID ARG GROUP_ID -RUN groupadd -g ${GROUP_ID} dev && \ - useradd -m -u $USER_ID -g $GROUP_ID dev +RUN addgroup --gid ${GROUP_ID} dev && \ + adduser --uid ${USER_ID} -G dev -D dev USER dev \ No newline at end of file diff --git a/example/compose/authelia/Dockerfile.frontend b/example/compose/authelia/Dockerfile.frontend index 823d3c8e..619e9f38 100644 --- a/example/compose/authelia/Dockerfile.frontend +++ b/example/compose/authelia/Dockerfile.frontend @@ -1,9 +1,9 @@ -FROM node:11-stretch-slim +FROM node:12-alpine ARG USER_ID ARG GROUP_ID -RUN cat /etc/passwd && userdel -rf node && \ - groupadd -g ${GROUP_ID} dev && \ - useradd -m -u $USER_ID -g $GROUP_ID dev +RUN deluser node && \ + addgroup --gid ${GROUP_ID} dev && \ + adduser --uid ${USER_ID} -G dev -D dev USER dev \ No newline at end of file diff --git a/example/compose/authelia/docker-compose.backend-dist.yml b/example/compose/authelia/docker-compose.backend-dist.yml new file mode 100644 index 00000000..6b5a3ef6 --- /dev/null +++ b/example/compose/authelia/docker-compose.backend-dist.yml @@ -0,0 +1,14 @@ +version: "3" +services: + authelia-backend: + build: + context: . + dockerfile: Dockerfile + volumes: + - "/tmp/authelia:/tmp/authelia" + environment: + - ENVIRONMENT=dev + restart: always + networks: + authelianet: + ipv4_address: 192.168.240.50 diff --git a/example/compose/authelia/docker-compose.backend.yml b/example/compose/authelia/docker-compose.backend.yml index 101f2727..0bab39b6 100644 --- a/example/compose/authelia/docker-compose.backend.yml +++ b/example/compose/authelia/docker-compose.backend.yml @@ -4,6 +4,9 @@ services: build: context: example/compose/authelia dockerfile: Dockerfile.backend + args: + USER_ID: ${USER_ID} + GROUP_ID: ${GROUP_ID} command: /resources/entrypoint.sh working_dir: /app volumes: diff --git a/example/compose/authelia/docker-compose.frontend-forward.yml b/example/compose/authelia/docker-compose.frontend-dist.yml similarity index 93% rename from example/compose/authelia/docker-compose.frontend-forward.yml rename to example/compose/authelia/docker-compose.frontend-dist.yml index c4450d63..c47c7e74 100644 --- a/example/compose/authelia/docker-compose.frontend-forward.yml +++ b/example/compose/authelia/docker-compose.frontend-dist.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" services: authelia-frontend: image: nginx:alpine diff --git a/example/compose/authelia/docker-compose.frontend.yml b/example/compose/authelia/docker-compose.frontend.yml index f5671e02..4172fb9a 100644 --- a/example/compose/authelia/docker-compose.frontend.yml +++ b/example/compose/authelia/docker-compose.frontend.yml @@ -1,10 +1,13 @@ -version: '3' +version: "3" services: authelia-frontend: build: context: example/compose/authelia dockerfile: Dockerfile.frontend - command: npm run start + args: + USER_ID: ${USER_ID} + GROUP_ID: ${GROUP_ID} + command: sh -c 'npm ci && npm run start' working_dir: /app volumes: - "./web:/app" diff --git a/example/compose/authelia/resources/entrypoint.sh b/example/compose/authelia/resources/entrypoint.sh index 54469e10..e1ba78ba 100755 --- a/example/compose/authelia/resources/entrypoint.sh +++ b/example/compose/authelia/resources/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -x diff --git a/example/compose/authelia/resources/nginx.conf b/example/compose/authelia/resources/nginx.conf index 486df698..163f3ef5 100644 --- a/example/compose/authelia/resources/nginx.conf +++ b/example/compose/authelia/resources/nginx.conf @@ -7,11 +7,11 @@ events { http { server { - listen 80; + listen 3000; location / { proxy_set_header Host $http_host; - proxy_pass http://authelia-backend; + proxy_pass http://authelia-backend:9091; } } } \ No newline at end of file diff --git a/example/compose/authelia/resources/run.sh b/example/compose/authelia/resources/run.sh index e20ed017..8a0c1a00 100755 --- a/example/compose/authelia/resources/run.sh +++ b/example/compose/authelia/resources/run.sh @@ -1,30 +1,12 @@ -#!/bin/bash +#!/bin/sh set -e -# Retries a command on failure. -# $1 - the max number of attempts -# $2... - the command to run - -retry() { - local -r -i max_attempts="$1"; shift - local -r cmd="$@" - local -i attempt_num=1 - until $cmd - do - if ((attempt_num==max_attempts)) - then - echo "Attempt $attempt_num failed and there are no more attempts left!" - return 1 - else - echo "Attempt $attempt_num failed! Trying again in 10 seconds..." - sleep 10 - fi - done -} - - # Build the binary go build -o /tmp/authelia/authelia-tmp cmd/authelia/main.go -retry 3 /tmp/authelia/authelia-tmp -config /etc/authelia/configuration.yml \ No newline at end of file +while true; +do + /tmp/authelia/authelia-tmp -config /etc/authelia/configuration.yml + sleep 10 +done \ No newline at end of file diff --git a/example/compose/duo-api/Dockerfile b/example/compose/duo-api/Dockerfile index fc70d55d..1fda8f71 100644 --- a/example/compose/duo-api/Dockerfile +++ b/example/compose/duo-api/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8.7.0-alpine +FROM node:12-alpine WORKDIR /usr/app/src diff --git a/example/compose/duo-api/docker-compose.yml b/example/compose/duo-api/docker-compose.yml index 4309e963..d2628bed 100644 --- a/example/compose/duo-api/docker-compose.yml +++ b/example/compose/duo-api/docker-compose.yml @@ -1,6 +1,7 @@ -version: '3' +version: "3" services: duo-api: - image: authelia-duo-api + build: + context: ./example/compose/duo-api networks: - authelianet diff --git a/example/compose/duo-api/duo_api.js b/example/compose/duo-api/duo_api.js index 5181f5c7..23761cde 100644 --- a/example/compose/duo-api/duo_api.js +++ b/example/compose/duo-api/duo_api.js @@ -16,36 +16,40 @@ let permission = 'allow'; app.post('/allow', (req, res) => { permission = 'allow'; + console.log("set allowed!"); res.send('ALLOWED'); }); app.post('/deny', (req, res) => { permission = 'deny'; + console.log("set denied!"); res.send('DENIED'); }); app.post('/auth/v2/auth', (req, res) => { - let response; - if (permission == 'allow') { - response = { - response: { - result: 'allow', - status: 'allow', - status_msg: 'The user allowed access.', - }, - stat: 'OK', - }; - } else { - response = { - response: { - result: 'deny', - status: 'deny', - status_msg: 'The user denied access.', - }, - stat: 'OK', - }; - } - setTimeout(() => res.json(response), 2000); + setTimeout(() => { + let response; + if (permission == 'allow') { + response = { + response: { + result: 'allow', + status: 'allow', + status_msg: 'The user allowed access.', + }, + stat: 'OK', + }; + } else { + response = { + response: { + result: 'deny', + status: 'deny', + status_msg: 'The user denied access.', + }, + stat: 'OK', + }; + } + res.json(response); + }, 2000); }); app.listen(port, () => console.log(`Duo API listening on port ${port}!`)); diff --git a/example/compose/ldap/base.ldif b/example/compose/ldap/base.ldif index 3136eb89..3d78917d 100644 --- a/example/compose/ldap/base.ldif +++ b/example/compose/ldap/base.ldif @@ -15,8 +15,8 @@ member: cn=bob,ou=users,dc=example,dc=com objectclass: groupOfNames objectclass: top -dn: cn=admin,ou=groups,dc=example,dc=com -cn: admin +dn: cn=admins,ou=groups,dc=example,dc=com +cn: admins member: cn=john,ou=users,dc=example,dc=com objectclass: groupOfNames objectclass: top diff --git a/example/compose/nginx/backend/Dockerfile b/example/compose/nginx/backend/Dockerfile index 04c97bf3..e119e442 100644 --- a/example/compose/nginx/backend/Dockerfile +++ b/example/compose/nginx/backend/Dockerfile @@ -1,4 +1,4 @@ FROM nginx:alpine -ADD ./html /usr/share/nginx/html -ADD ./nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +ADD html /usr/share/nginx/html +ADD nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/example/compose/nginx/backend/docker-compose.yml b/example/compose/nginx/backend/docker-compose.yml index e5bdf67e..63a4b525 100644 --- a/example/compose/nginx/backend/docker-compose.yml +++ b/example/compose/nginx/backend/docker-compose.yml @@ -1,10 +1,11 @@ -version: '3' +version: "3" services: nginx-backend: - image: authelia-example-backend + build: + context: example/compose/nginx/backend labels: - traefik.frontend.rule=Host:home.example.com,public.example.com,secure.example.com,admin.example.com,singlefactor.example.com - - traefik.frontend.auth.forward.address=http://192.168.240.1:9091/api/verify?rd=https://login.example.com:8080/%23/ + - traefik.frontend.auth.forward.address=http://authelia-backend:9091/api/verify?rd=https://login.example.com:8080/ - traefik.frontend.auth.forward.tls.insecureSkipVerify=true networks: - authelianet diff --git a/example/compose/nginx/backend/html/admin/secret.html b/example/compose/nginx/backend/html/admin/secret.html index b44f4b6c..3cb5dce0 100644 --- a/example/compose/nginx/backend/html/admin/secret.html +++ b/example/compose/nginx/backend/html/admin/secret.html @@ -1,10 +1,13 @@ -
-