2017-01-29 15:29:36 +00:00
# Authelia
2016-12-18 11:35:56 +00:00
2016-12-18 12:26:14 +00:00
[![license ](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000 )][MIT License]
2017-01-29 15:29:36 +00:00
[![Build ](https://travis-ci.org/clems4ever/authelia.svg?branch=master )](https://travis-ci.org/clems4ever/authelia)
2017-07-17 22:50:47 +00:00
[![Gitter ](https://img.shields.io/gitter/room/badges/shields.svg )](https://gitter.im/authelia/general?utm_source=share-link& utm_medium=link& utm_campaign=share-link)
2016-12-17 19:19:10 +00:00
2017-01-29 15:29:36 +00:00
**Authelia** is a complete HTTP 2-factor authentication server for proxies like
2017-06-29 09:51:52 +00:00
nginx. It has been made to work with nginx [auth_request] module and is currently
2017-01-29 15:29:36 +00:00
used in production to secure internal services in a small docker swarm cluster.
2017-07-13 22:52:07 +00:00
# Table of Contents
1. [Features summary ](#features-summary )
2. [Deployment ](#deployment )
1. [With NPM ](#with-npm )
2. [With Docker ](#with-docker )
3. [Getting started ](#getting-started )
1. [Pre-requisites ](#pre-requisites )
2. [Run it! ](#run-it )
4. [Features in details ](#features-in-details )
1. [First factor with LDAP and ACL ](#first-factor-with-ldap-and-acl )
2. [Second factor with TOTP ](#second-factor-with-totp )
3. [Second factor with U2F security keys ](#second-factor-with-u2f-security-keys )
4. [Password reset ](#password-reset )
5. [Access control ](#access-control )
6. [Session management with Redis ](#session-management-with-redis )
4. [Documentation ](#documentation )
1. [Authelia configuration ](#authelia-configuration )
1. [API documentation ](#api-documentation )
5. [Contributing to Authelia ](#contributing-to-authelia )
6. [License ](#license )
---
## Features summary
2017-01-29 15:29:36 +00:00
* Two-factor authentication using either
**[TOTP] - Time-Base One Time password -** or ** [U2F] - Universal 2-Factor -**
as 2nd factor.
* Password reset with identity verification by sending links to user email
address.
* Access restriction after too many authentication attempts.
2017-07-13 22:52:07 +00:00
* Session management using Redis key/value store.
2016-12-17 19:19:10 +00:00
2017-01-29 16:01:12 +00:00
## Deployment
2017-06-29 09:51:52 +00:00
If you don't have any LDAP and/or nginx setup yet, I advise you to follow the
[Getting Started ](#Getting-started ) section. That way, you can test it right away
without even configure anything.
2017-01-29 16:05:15 +00:00
2017-06-29 09:51:52 +00:00
Otherwise here are the available steps to deploy **Authelia** on your machine given
2017-07-20 09:43:48 +00:00
your configuration file is ** /path/to/your/config.yml**. Note that you can create your
2017-09-03 13:22:09 +00:00
own the configuration file from [config.template.yml] at the root of the repo.
2017-01-29 16:05:15 +00:00
2017-01-29 16:01:12 +00:00
### With NPM
npm install -g authelia
2017-06-29 09:51:52 +00:00
authelia /path/to/your/config.yml
2017-01-29 16:01:12 +00:00
2017-01-29 16:05:15 +00:00
### With Docker
2017-01-29 16:01:12 +00:00
docker pull clems4ever/authelia
2017-06-29 09:51:52 +00:00
docker run -v /path/to/your/config.yml:/etc/authelia/config.yml -v /path/to/data/dir:/var/lib/authelia clems4ever/authelia
where ** /path/to/data/dir** is the directory where all user data will be stored.
2017-01-29 16:01:12 +00:00
2016-12-17 19:19:10 +00:00
## Getting started
2017-01-29 15:29:36 +00:00
The provided example is docker-based so that you can deploy and test it very
2017-06-29 09:51:52 +00:00
quickly.
### Pre-requisites
#### npm
Make sure you have npm and node installed on your computer.
#### Docker
Make sure you have **docker** and **docker-compose** installed on your machine.
For your information, here are the versions that have been used for testing:
docker --version
gave *Docker version 17.03.1-ce, build c6d412e* .
docker-compose --version
gave *docker-compose version 1.14.0, build c7bdf9e* .
#### Available port
Make sure you don't have anything listening on port 8080.
#### Subdomain aliases
Add the following lines to your ** /etc/hosts** to alias multiple subdomains so that nginx can redirect request to the correct virtual host.
2017-03-15 22:51:29 +00:00
2017-03-25 17:42:48 +00:00
127.0.0.1 home.test.local
2017-09-03 13:22:09 +00:00
127.0.0.1 public.test.local
127.0.0.1 dev.test.local
127.0.0.1 admin.test.local
2017-03-25 17:42:48 +00:00
127.0.0.1 mx1.mail.test.local
127.0.0.1 mx2.mail.test.local
2017-03-15 22:51:29 +00:00
127.0.0.1 auth.test.local
2017-06-29 09:51:52 +00:00
2017-07-13 22:52:07 +00:00
### Run it!
2017-03-15 22:51:29 +00:00
2017-08-08 14:03:12 +00:00
Deploy the **Authelia** example with one of the following commands:
Build Docker container from current commit:
2016-12-17 19:19:10 +00:00
2017-06-13 23:09:19 +00:00
npm install --only=dev
2017-06-29 09:51:52 +00:00
./node_modules/.bin/grunt build-dist
2017-08-08 14:03:12 +00:00
./scripts/example-commit/deploy-example.sh
Use provided container on [DockerHub ](https://hub.docker.com/r/clems4ever/authelia/ ):
2016-12-17 19:19:10 +00:00
2017-08-08 14:03:12 +00:00
./scripts/example-dockerhub/deploy-example.sh
2017-01-29 15:29:36 +00:00
After few seconds the services should be running and you should be able to visit
2017-06-29 09:51:52 +00:00
[https://home.test.local:8080/ ](https://home.test.local:8080/ ).
When accessing the login page, a self-signed certificate exception should appear,
it has to be trusted before you can get to the target page. The certificate
2017-09-03 13:22:09 +00:00
must also be trusted for each subdomain, therefore it is normal to see the exception
2017-06-29 09:51:52 +00:00
several times.
2017-01-29 15:29:36 +00:00
2017-06-29 09:51:52 +00:00
Below is what the login page looks like:
2017-01-29 15:29:36 +00:00
2017-06-14 21:34:11 +00:00
< img src = "https://raw.githubusercontent.com/clems4ever/authelia/master/images/first_factor.png" width = "400" >
2017-01-29 15:29:36 +00:00
2017-07-13 22:52:07 +00:00
## Features in details
2017-09-03 13:22:09 +00:00
### First factor using an LDAP server
**Authelia** uses an LDAP server as the backend for storing credentials.
When authentication is needed, the user is redirected to the login page which
corresponds to the first factor. Authelia tries to bind the username and password
against the configured LDAP backend.
2017-01-29 15:29:36 +00:00
2017-09-03 13:22:09 +00:00
You can find an example of the configuration of the LDAP backend in [config.template.yml].
2017-06-14 21:34:11 +00:00
< img src = "https://raw.githubusercontent.com/clems4ever/authelia/master/images/second_factor.png" width = "400" >
2016-12-18 11:50:33 +00:00
2016-12-17 19:19:10 +00:00
2017-07-13 22:52:07 +00:00
### Second factor with TOTP
2017-09-03 13:22:09 +00:00
In **Authelia** , you can register a per user TOTP (Time-Based One Time Password) secret before
2017-01-29 15:29:36 +00:00
authenticating. To do that, you need to click on the register button. It will
2017-09-03 13:22:09 +00:00
send a link to the user email address defined in the LDAP.
Since this is an example, no email will be sent, the link is rather delivered in the file
2017-09-02 23:25:43 +00:00
**/tmp/notifications/notification.txt**. Paste the link in your browser and you'll get
2017-09-03 13:22:09 +00:00
your secret in QRCode and Base32 format. You can use
2017-06-29 09:51:52 +00:00
[Google Authenticator]
to store them and get the generated tokens with the app.
2016-12-17 19:19:10 +00:00
2017-06-14 21:34:11 +00:00
< img src = "https://raw.githubusercontent.com/clems4ever/authelia/master/images/totp.png" width = "400" >
2016-12-17 19:19:10 +00:00
2017-07-13 22:52:07 +00:00
### Second factor with U2F security keys
**Authelia** also offers authentication using U2F (Universal 2-Factor) devices like [Yubikey ](Yubikey )
2017-01-29 15:29:36 +00:00
USB security keys. U2F is one of the most secure authentication protocol and is
2017-06-29 09:51:52 +00:00
already available for Google, Facebook, Github accounts and more.
2016-12-17 19:19:10 +00:00
2017-09-03 13:22:09 +00:00
Like TOTP, U2F requires you register a security key before authenticating.
To do so, click on the register link. This will send a link to the
2017-01-29 15:29:36 +00:00
user email address. Since this is an example, no email will be sent, the
2017-09-02 23:25:43 +00:00
link is rather delivered in the file ** /tmp/notifications/notification.txt**. Paste
2017-01-29 15:29:36 +00:00
the link in your browser and you'll be asking to touch the token of your device
2017-06-29 09:51:52 +00:00
to register. Upon successful registration, you can authenticate using your U2F
device by simply touching the token. Easy, right?!
2017-01-29 15:29:36 +00:00
2017-06-14 21:34:11 +00:00
< img src = "https://raw.githubusercontent.com/clems4ever/authelia/master/images/u2f.png" width = "400" >
2017-01-29 15:29:36 +00:00
### Password reset
With **Authelia** , you can also reset your password in no time. Click on the
2017-06-29 09:51:52 +00:00
**Forgot password?** link in the login page, provide the username of the user requiring
2017-01-29 15:29:36 +00:00
a password reset and **Authelia** will send an email with an link to the user
email address. For the sake of the example, the email is delivered in the file
2017-09-02 23:25:43 +00:00
**/tmp/notifications/notification.txt**.
2017-01-29 15:29:36 +00:00
Paste the link in your browser and you should be able to reset the password.
2016-12-17 19:19:10 +00:00
2017-06-14 21:34:11 +00:00
< img src = "https://raw.githubusercontent.com/clems4ever/authelia/master/images/reset_password.png" width = "400" >
2017-05-25 13:09:29 +00:00
2017-03-25 14:38:27 +00:00
### Access Control
2017-09-03 13:22:09 +00:00
With **Authelia** , you can define your own access control rules for finely restricting
user access to some resources and subdomains. Those rules are defined and fully documented
in the configuration file. They can apply to users, groups or everyone.
Check out [config.template.yml] to see how they are defined.
2017-03-25 14:38:27 +00:00
2017-07-13 22:52:07 +00:00
### Session management with Redis
2017-09-03 13:22:09 +00:00
When your users authenticate against Authelia, sessions are stored in a Redis key/value store. You can specify your own Redis instance in [config.template.yml].
2017-07-13 22:52:07 +00:00
2016-12-17 19:50:50 +00:00
## Documentation
2017-07-13 22:52:07 +00:00
### Authelia configuration
2017-01-29 15:55:23 +00:00
The configuration of the server is defined in the file
2017-09-03 13:22:09 +00:00
[config.template.yml]. All the details are documented there.
2017-01-29 15:55:23 +00:00
You can specify another configuration file by giving it as first argument of
**Authelia**.
authelia config.custom.yml
2017-01-29 15:29:36 +00:00
### API documentation
There is a complete API documentation generated with
[apiDoc ](http://apidocjs.com/ ) and embedded in the repo under the **doc/**
directory. Simply open index.html locally to watch it.
## Contributing to Authelia
2016-12-18 11:56:24 +00:00
Follow [contributing ](CONTRIBUTORS.md ) file.
2016-12-17 19:19:10 +00:00
## License
2017-01-29 15:29:36 +00:00
**Authelia** is **licensed** under the ** [MIT License]**. The terms of the license are as follows:
2016-12-17 19:19:10 +00:00
The MIT License (MIT)
Copyright (c) 2016 - Clement Michaud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[MIT License]: https://opensource.org/licenses/MIT
2017-01-29 15:29:36 +00:00
[TOTP]: https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
[U2F]: https://www.yubico.com/about/background/fido/
[Yubikey]: https://www.yubico.com/products/yubikey-hardware/yubikey4/
2017-06-29 09:51:52 +00:00
[auth_request]: http://nginx.org/en/docs/http/ngx_http_auth_request_module.html
[Google Authenticator]: https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2& hl=en
2017-09-03 13:22:09 +00:00
[config.template.yml]: https://github.com/clems4ever/authelia/blob/master/config.template.yml
2017-01-29 15:29:36 +00:00