Interface | Description |
---|---|
HtpasswdAuth |
An extension of AuthProvider which is using htpasswd file as store
|
Class | Description |
---|---|
HtpasswdAuthOptions |
Options configuring htpasswd authentication.
|
We provide an implementation of AuthProvider
which uses the Apache htpasswd file format
to perform authentication. The provider will not watch for updates to the file after loading. If you need dynamic
user management it would be more convenient to use dynamic providers such as jdbc or mongo providers.
To use this project, add the following dependency to the _dependencies_ section of your build descriptor:
* Maven (in your `pom.xml`):
[source,xml,subs="+attributes"]
----
* Gradle (in your `build.gradle` file):
[source,groovy,subs="+attributes"] ---- compile '${maven.groupId}:${maven.artifactId}:${maven.version}' ----
To create an instance you first need an htpasswd file. This file is created using the apache htpasswd tool.
Once you've got one of these you can create a HtpasswdAuth
instance as follows:
[source,$lang]
----
examples.AuthHtpasswdExamples#example1(io.vertx.core.Vertx)
----
Once you've got your instance you can authenticate with it just like any AuthProvider
.
The out of the box config assumes the usage of the file htpasswd in the root of the project.
== Provider internal behavior
The provider will load the specified htpasswd file at start time and will not watch for modifications. If you require dynamic reloads, you will need to restart the provider.
The implementation does not have any other state than the htpasswd file itself.
== Authentication
When authenticating using this implementation, it assumes that the username and password are parsed as a JSON object which we refer from now on as authentication info:
[source,$lang]
----
examples.AuthHtpasswdExamples#example2(HtpasswdAuth)
----
== Autorization
Apache htpasswd file is a pure authentication mechanism and not authorization but still it is possible to configure default authorization response for all users and for all authorities. It can ether allow or deny all.
* Configuration example:
[source,$lang]
----
examples.AuthHtpasswdExamples#example3(io.vertx.core.Vertx)
----
* Authorization checking:
[source,$lang]
----
examples.AuthHtpasswdExamples#example4
----
Copyright © 2018 Eclipse. All rights reserved.