From 4cbf6efa421468ae4765d30f48ad38562a5e2dc7 Mon Sep 17 00:00:00 2001
From: Clement Michaud
Date: Sun, 24 Sep 2017 23:19:03 +0200
Subject: [PATCH] Disable second factor for certain subdomain
---
.travis.yml | 15 +-
Gruntfile.js | 2 +-
docker-compose.dev.yml | 2 +-
.../html/basicauth.test.local/secret.html | 10 +
example/nginx/html/home.test.local/index.html | 19 +-
example/nginx/nginx.conf | 37 ++
.../lib/firstfactor/FirstFactorValidator.ts | 35 +-
src/client/lib/firstfactor/index.ts | 17 +-
src/client/lib/secondfactor/index.ts | 11 +-
src/server/constants.ts | 4 +
src/server/lib/ErrorReplies.ts | 2 +-
.../lib/access_control/AccessController.ts | 2 +
src/server/lib/ldap/Client.ts | 2 +-
src/server/lib/routes/firstfactor/get.ts | 23 +-
src/server/lib/routes/firstfactor/post.ts | 24 +-
.../lib/routes/password-reset/form/post.ts | 53 +-
src/server/lib/routes/verify/get.ts | 21 +-
test/features/access-control.feature | 3 +
test/features/basic-auth.feature | 19 +
test/features/redirection.feature | 2 +-
test/features/resilience.feature | 4 +-
.../step_definitions/authentication.ts | 7 +-
test/features/step_definitions/redirection.ts | 2 +-
test/features/support/world.ts | 4 +
.../firstfactor/FirstFactorValidator.test.ts | 10 +-
.../access_control/AccessController.test.ts | 626 +++++++++---------
test/unit/server/mocks/ServerVariablesMock.ts | 60 +-
.../server/routes/firstfactor/post.test.ts | 4 +-
test/unit/server/routes/verify/get.test.ts | 195 +++---
29 files changed, 683 insertions(+), 532 deletions(-)
create mode 100644 example/nginx/html/basicauth.test.local/secret.html
create mode 100644 src/server/constants.ts
create mode 100644 test/features/basic-auth.feature
diff --git a/.travis.yml b/.travis.yml
index ab6c78eab..61a611250 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,13 +15,14 @@ addons:
- libgif-dev
- google-chrome-stable
hosts:
- - auth.test.local
- - home.test.local
- - public.test.local
- - admin.test.local
- - dev.test.local
- - mx1.mail.test.local
- - mx2.mail.test.local
+ - admin.test.local
+ - auth.test.local
+ - basicauth.test.local
+ - dev.test.local
+ - home.test.local
+ - mx1.mail.test.local
+ - mx2.mail.test.local
+ - public.test.local
before_install:
- npm install -g npm@'>=2.13.5'
diff --git a/Gruntfile.js b/Gruntfile.js
index d8593e43a..1dd853675 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -26,7 +26,7 @@ module.exports = function (grunt) {
},
"docker-restart": {
cmd: "./scripts/dc-dev.sh",
- args: ['up', '-d']
+ args: ['restart', 'authelia']
},
"minify": {
cmd: "./node_modules/.bin/uglifyjs",
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 6f48df1f4..196ecac5f 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -5,6 +5,6 @@ services:
- ./test:/usr/src/test
- ./dist/src/server:/usr/src
- ./node_modules:/usr/src/node_modules
- - ./config.yml:/etc/authelia/config.yml:ro
+ - ./config.template.yml:/etc/authelia/config.yml:ro
networks:
- example-network
diff --git a/example/nginx/html/basicauth.test.local/secret.html b/example/nginx/html/basicauth.test.local/secret.html
new file mode 100644
index 000000000..386bd8931
--- /dev/null
+++ b/example/nginx/html/basicauth.test.local/secret.html
@@ -0,0 +1,10 @@
+
+
+ Secret
+
+
+
+ This is a very important secret!
+ Go back to home page .
+
+
diff --git a/example/nginx/html/home.test.local/index.html b/example/nginx/html/home.test.local/index.html
index a96dee5cc..ad0f2069b 100644
--- a/example/nginx/html/home.test.local/index.html
+++ b/example/nginx/html/home.test.local/index.html
@@ -8,8 +8,8 @@
Access the secret
- You need to log in to access the secret!
- Try to access it using one of the following links to test access control powered by Authelia.
+ You need to log in to access the secret! Try to access it using
+ one of the following links to test access control powered by Authelia.
You can also log off by visiting the following link .
List of users
Here is the list of credentials you can log in with to test access control.
-
- Once first factor is passed, you will need to follow the links to register a secret for the second factor.
- Authelia will send you a fictituous email that will be in the file
- /tmp/notifications/notification.txt .
- It will provide you with the link to complete the registration allowing you to authenticate with 2-factor.
+ Once first factor is passed, you will need to follow the links to register a secret for the second factor. Authelia
+ will send you a fictituous email that will be in the file
+ /tmp/notifications/notification.txt . It will provide you with the link to complete the registration
+ allowing you to authenticate with 2-factor.
john / password : belongs to admin and dev groups.
@@ -70,7 +72,7 @@
Access control rules
-
These rules are extracted from the configuration file
+
These rules are extracted from the configuration file
config.template.yml .
# Default policy can either be `allow` or `deny`.
@@ -129,4 +131,5 @@ users:
resources:
- '^/users/harry/.*$'
+