diff --git a/README.md b/README.md index 584b6f8c..52d8e0a3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ Add the following lines to your /etc/hosts to simulate multiple subdomains 127.0.0.1 secret.test.local 127.0.0.1 secret1.test.local 127.0.0.1 secret2.test.local + 127.0.0.1 home.test.local + 127.0.0.1 mx1.mail.test.local + 127.0.0.1 mx2.mail.test.local 127.0.0.1 auth.test.local Then, type the following command to build and deploy the services: @@ -48,15 +51,28 @@ Then, type the following command to build and deploy the services: docker-compose up -d After few seconds the services should be running and you should be able to visit -[https://secret.test.local:8080/](https://secret.test.local:8080/). +[https://home.test.local:8080/](https://home.test.local:8080/). Normally, a self-signed certificate exception should appear, it has to be accepted before getting to the login page: ![first-factor-page](https://raw.githubusercontent.com/clems4ever/authelia/master/images/first_factor.png) -### 1st factor: LDAP -An LDAP server has been deployed for you with the following credentials: **user/password**. +### 1st factor: LDAP and ACL +An LDAP server has been deployed for you with the following credentials and +access control list: + +- **john / password** is in the admin group and has access to the secret from +any subdomain. +- **bob / password** is in the dev group and has access to the secret from + - [secret.test.local](https://secret.test.local:8080/secret.html) + - [secret2.test.local](https://secret2.test.local:8080/secret.html) + - [home.test.local](https://home.test.local:8080/secret.html) + - [\*.mail.test.local](https://mx1.mail.test.local:8080/secret.html) +- **harry / password** is not in a group but has rules giving him has access to + the secret from + - [secret1.test.local](https://secret1.test.local:8080/secret.html) + - [home.test.local](https://home.test.local:8080/secret.html) Type them in the login page and validate. Then, the second factor page should have appeared as shown below. @@ -99,6 +115,12 @@ email address. For the sake of the example, the email is delivered in the file ./notifications/notification.txt. Paste the link in your browser and you should be able to reset the password. +### Access Control +With **Authelia**, you can define your own access control rules for restricting +the access to certain subdomains to your users. Those rules are defined in the +configuration file and can be either default, per-user or per-group policies. +Check out the *config.template.yml* to see how they are defined. + ## Documentation ### Configuration The configuration of the server is defined in the file diff --git a/config.template.yml b/config.template.yml index e1ab5244..a70c8d3c 100644 --- a/config.template.yml +++ b/config.template.yml @@ -1,17 +1,67 @@ +# The port to listen on +port: 80 + +# Log level +# # Level of verbosity for logs logs_level: info -# Configuration of LDAP +# LDAP configuration +# # Example: for user john, the DN will be cn=john,ou=users,dc=example,dc=com ldap: + # The url of the ldap server url: ldap://ldap - user_search_base: ou=users,dc=example,dc=com - user_search_filter: cn + + # The base dn for every entries + base_dn: dc=example,dc=com + + # An additional dn to define the scope to all users + additional_user_dn: ou=users + + # The user name attribute of users. Might uid for FreeIPA. 'cn' by default. + user_name_attribute: cn + + # An additional dn to define the scope of groups + additional_group_dn: ou=groups + + # The group name attribute of group. 'cn' by default. + group_name_attribute: cn + + # The username and password of the admin user. user: cn=admin,dc=example,dc=com password: password +# Access Control +# +# Access control is a set of rules you can use to restrict the user access. +# Default (anyone), per-user or per-group rules can be defined. +# +# If 'access_control' is not defined, ACL rules are disabled and default policy +# is applied, i.e., access is allowed to anyone. Otherwise restrictions follow +# the rules defined below. +# If no rule is provided, all domains are denied. +# +# '*' means 'any' subdomains and matches any string. It must stand at the +# beginning of the pattern. +access_control: + default: + - home.test.local + groups: + admin: + - '*.test.local' + dev: + - secret.test.local + - secret2.test.local + users: + harry: + - secret1.test.local + bob: + - '*.mail.test.local' + + # Configuration of session cookies # # _secret_ the secret to encrypt session cookies diff --git a/docker-compose.yml b/docker-compose.yml index bf30b905..bfaaeb33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,9 @@ services: - SLAPD_ORGANISATION=MyCompany - SLAPD_DOMAIN=example.com - SLAPD_PASSWORD=password + - SLAPD_ADDITIONAL_MODULES=memberof + - SLAPD_ADDITIONAL_SCHEMAS=openldap + - SLAPD_FORCE_RECONFIGURE=true expose: - "389" volumes: diff --git a/example/ldap/base.ldif b/example/ldap/base.ldif index 1e46c0ef..07d4e5a8 100644 --- a/example/ldap/base.ldif +++ b/example/ldap/base.ldif @@ -8,39 +8,55 @@ objectclass: organizationalUnit objectclass: top ou: users -dn: cn=user,ou=groups,dc=example,dc=com -cn: user -gidnumber: 502 -objectclass: posixGroup +dn: cn=dev,ou=groups,dc=example,dc=com +cn: dev +member: cn=john,ou=users,dc=example,dc=com +member: cn=bob,ou=users,dc=example,dc=com +objectclass: groupOfNames objectclass: top -dn: cn=user,ou=users,dc=example,dc=com -cn: user -gidnumber: 500 -givenname: user -homedirectory: /home/user1 -loginshell: /bin/sh -objectclass: inetOrgPerson -objectclass: posixAccount +dn: cn=admin,ou=groups,dc=example,dc=com +cn: admin +member: cn=john,ou=users,dc=example,dc=com +objectclass: groupOfNames objectclass: top -mail: user@example.com -sn: User -uid: user -uidnumber: 1000 + +dn: cn=john,ou=users,dc=example,dc=com +cn: john +objectclass: inetOrgPerson +objectclass: top +mail: john.doe@example.com +sn: John Doe userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= -dn: uid=useruid,ou=users,dc=example,dc=com -cn: useruid -gidnumber: 500 -givenname: user -homedirectory: /home/user1 -loginshell: /bin/sh +dn: cn=harry,ou=users,dc=example,dc=com +cn: harry objectclass: inetOrgPerson -objectclass: posixAccount objectclass: top -mail: useruid@example.com -sn: User -uid: useruid -uidnumber: 1001 +mail: harry.potter@example.com +sn: Harry Potter userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= +dn: cn=bob,ou=users,dc=example,dc=com +cn: bob +objectclass: inetOrgPerson +objectclass: top +mail: bob.dylan@example.com +sn: Bob Dylan +userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= + +# dn: uid=jack,ou=users,dc=example,dc=com +# cn: jack +# gidnumber: 501 +# givenname: Jack +# homedirectory: /home/jack +# loginshell: /bin/sh +# objectclass: inetOrgPerson +# objectclass: posixAccount +# objectclass: top +# mail: jack.daniels@example.com +# sn: Jack Daniels +# uid: jack +# uidnumber: 1001 +# userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= +# diff --git a/example/nginx_conf/index.html b/example/nginx_conf/index.html index c59b1e20..6eb9a534 100644 --- a/example/nginx_conf/index.html +++ b/example/nginx_conf/index.html @@ -3,8 +3,81 @@