Check access to an HTTP endpoint using an identity store.
(Currently only POST requests are supported and the response is dropped.)
Supported identity stores are:
- LDAP
- JSON file
$ cargo build$ nix-buildWith Nix you can also easily cross-compile entman:
$ nix-build '<nixpkgs>' \
--arg crossSystem '{ config = "aarch64-unknown-linux-gnu"; }' \
--arg overlays '[ (self: super: { entman = super.callPackage ./. {}; }) ]' \
-A entmanIn the working directory where entman is executed, there must be a
entman.toml configuration file.
A good start is to copy the entman.toml.example from this repository.
Prefix to the paths where the HTTP endpoints are mounted.
The port on which the HTTP endpoints are served.
The URL to the endpoint accessed in case of a successful authorization.
Example: "http://localhost:8020/castle/lock?toggle"
Path to the log file to write to. This can be an absolute or relative path. A relative path is relative to the working directory where entman is executed. See also #log.
Which kind of identity store to use.
Possible values are "Ldap" and "Json".
Configuration for the LDAP identity store.
Example: "ldap://localhost:389"
Example: "dc=example"
Example: "cn=admin,dc=example"
Example: "12345"
The filter used when querying the LDAP server.
Hereby %t is replaced by the access token.
Example: "(accessToken=%t)"
If that query produces exactly one match, then the access is granted.
If the query has more than one match, it is assumed that the access was revoked.
In the LDAP response, the name of the attribute that contains the username
assigned to the access token.
This is only used so as to log the username to the log.
Example: "uid"
Configuration for the JSON identity store.
The path to the file in JSON Lines format containing the identity data. Each line of the file must contain a JSON object of the following form:
{ "username": "name", "token": "accessToken", "access": true }Access is granted if the access attribute of the first JSON object in the file matching the token in question is set to true.
The username attribute is then used for the log.
If the access attribute of the first matching JSON object is false, it is assumed the access was revoked.
entman provides an HTTP endpoint /access.
For example, with mount_point = "/entman" and port = 8010, it is accessible
at http://localhost:8010/entman/access.
We use these configuration values in the further examples.
We have a subsection for each type of supported request:
Such a request returns the log or parts of it.
$ curl -X GET http://localhost:8010/entman/access?time_min=1546297200&time_max=1577833199&token=foo&name=jane-doe&outcome=success&only_latest=false
{"time":1546297200,"token":"foo","response":{"outcome":"Success","name":"jane-doe"}}Hereby each of the query parameters is optional. They have the following meanings.
time_min=: Mimimum"time"of returned lines.time_max=: Maximum"time"of returned lines.token=: Filter by"token".outcome=: Filter by lower case version of the"outcome".name=: Filter by"name".
This is the main feature of this program.
$ curl -X POST http://localhost:8010/entman/access?token=fooSuch a request performs an access using a provided token.
Then, a query of the identity provider is performed with the given token.
If that query is successful and entman performs a POST request to the configured
[client] endpoint.
The response to that POST request is dropped.
For each access a line is appended to the log file. Such a line looks as follows.
{"time":1546297200,"token":"foo","response":{"outcome":"Success","name":"jane-doe"}}Hereby:
"time"is the timestamp of the access."token"is the token used"response""outcome"is one of"Unknown","Success"and"Revoked"."Unknown"means that the token was not matched. In that case"name"isnull."Success"means that the token was matched exactly once. An attempt to access the[client] endpointhas subsequently been made. However, this does not tell anything about whether that attempt itself was successful."Revoked"means that the token was revoked. In that case"name"isnull.
"name"is, in case of a successful outcome, the name of the user whose token was matched.