libravatarserv/README.md

186 lines
5.4 KiB
Markdown
Raw Normal View History

2018-11-25 06:33:32 +01:00
**libravatarserv** is a simple [libravatar](https://www.libravatar.org/) server.
2018-11-26 02:25:25 +01:00
It is intended to be used as a
2018-11-24 11:00:07 +01:00
[CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) program.
2018-11-25 06:33:32 +01:00
Libravatar is a free service and an open specification for hosting profile
images tied to email or OpenID addresses.
## Features
* Avatar delivery based on email addresses
* Default avatar for unknown addresses
* MD5 hashes
* SHA256 hashes
2018-11-26 04:37:28 +01:00
* Variable image size (`s` or `size`)
2018-11-28 04:02:17 +01:00
* Default fallbacks (`d` or `default`): 404, URL, mp/mm, identicon
2018-11-26 04:37:28 +01:00
The default behaviour for unknown users is to return a 404 error. You can change
that by setting the environment variable `LIBRAVATARSERV_DEFAULT_FALLBACK` to
any value accepted by `d` or `default`. If a default image is put in the avatar
directory, that is returned instead. The default image can not be overridden by
adding the parameter `d` or `default` to the URL.
2018-11-25 06:33:32 +01:00
2018-11-26 05:20:46 +01:00
Clients are asked to cache results for up to 1 day to reduce load. This can
apply to negative results as well.
The API is explained in greater detail at the
[Libravar wiki](https://wiki.libravatar.org/api/).
2018-11-25 06:33:32 +01:00
2018-11-27 12:06:34 +01:00
### Not supported
* OpenID
* Because it isn't possible to store filenames with '/' in it on most filesystems.
2018-11-27 17:14:35 +01:00
* The default fallbacks monsterid, wavatar and retro
2018-11-27 12:06:34 +01:00
* Because I don't think anyone uses them?
* Patches welcome
2018-11-24 11:00:07 +01:00
## Usage
2018-11-25 06:33:32 +01:00
Install nginx and
[fcgiwrap](https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/),
copy the [example config](https://schlomp.space/tastytea/libravatarserv/src/branch/master/doc/nginx-example.conf) to the nginx configuration directory and edit it
according to your needs. Other webservers and cgi spawners will also work, of
course.
2018-11-25 07:59:17 +01:00
Add the following DNS records to your nameserver:
```PLAIN
_avatars._tcp.example.com. IN SRV 0 0 80 avatars.example.com
_avatars-sec._tcp.example.com. IN SRV 0 0 443 avatars.example.com
```
`_avatars._tcp.example.com` is for HTTP, `_avatars-sec._tcp.example.com` is for
HTTPS.
2018-11-25 06:33:32 +01:00
libravatarserv looks in each of `${XDG_DATA_DIRS}` for a directory named
`libravatarserv`. You can force a different directory by setting the environment
variable `LIBRAVATARSERV_DIR` (until 0.3.0 `AVATAR_DIR`).
2018-11-25 06:33:32 +01:00
2018-11-25 07:23:20 +01:00
The image files are named like your email address, no file extension. If you
want to deliver a default image for unknown email addresses, name it `default`.
If you want to support "Mystery persons" (mp/mm) as default avatars, place a
file named `mp` in the avatar dir. You can use the [default libravatar mystery
person](https://seccdn.libravatar.org/mm/512.png), for example.
2018-11-25 07:23:20 +01:00
Test your setup on https://www.libravatar.org/tools/check/.
### Example
2018-11-26 02:25:25 +01:00
The avatar directory could look like this:
2018-11-25 07:23:20 +01:00
```PLAIN
/usr/share/libravatarserv
├── [ 32K] default
├── [ 759] user@example.com
└── [ 16] user+newsletter@example.com -> user@example.com
```
2018-11-25 06:33:32 +01:00
### Configuration
Configuration is done through environment variables.
2018-11-27 17:15:47 +01:00
**LIBRAVATARSERV_DIR**
The directory containing the avatars.
Default: empty
2018-11-27 17:15:47 +01:00
**LIBRAVATARSERV_DEFAULT_FALLBACK**
Controls what happens if no fallback was requested.
2018-11-28 04:02:17 +01:00
Possible values: Anything that can be supplied with the `d` or `default`
parameter.
Default: 404
2018-11-27 17:15:47 +01:00
**LIBRAVATARSERV_REDIRECT_NOFALLBACK**
Set to 1 to redirect to libravatar.org if the requested fallback is not
supported.
Default: 0
2018-11-27 17:15:47 +01:00
**LIBRAVATARSERV_REDIRECT_NOUSER**
Set to 1 to redirect to libravatar.org if the user is not found.
Default: 0
### Things to keep in mind
libravatarserv resizes images on the fly and does not cache anything. It also
calculates both MD5 and SHA256 hashes for every user on every request. This
could seriously strain the ressources of your computer if many users use the
service.
2018-11-24 11:00:07 +01:00
## Install
2018-11-27 05:46:45 +01:00
### Gentoo
Gentoo ebuilds are available via my
[repository](https://schlomp.space/tastytea/overlay).
### Automatically generated packages
Binary packages are generated automatically for each
[release](https://schlomp.space/tastytea/libravatarserv/releases) in the
formats:
* deb
* rpm
* tar.gz
They are generated on Debian Stretch 64 bit and signed with my
2018-11-27 10:43:27 +01:00
[automatic signing key](https://tastytea.de/tastytea_autosign.asc).
2018-11-27 05:46:45 +01:00
Up to and including 0.6.2, the packages were generated on Ubuntu 16.04 64 bit.
2018-11-27 05:46:45 +01:00
### From source
#### Dependencies
2018-11-24 11:00:07 +01:00
2018-11-26 05:50:35 +01:00
* C++ compiler (tested: [gcc](https://gcc.gnu.org/) 5/6/7/8,
[clang](https://llvm.org/) 5/6)
2018-11-24 11:00:07 +01:00
* [cmake](https://cmake.org/) (at least 3.2)
2018-11-26 06:54:16 +01:00
* [crypto++](https://cryptopp.com) (tested: 7.0 / 5.6)
2018-11-27 05:46:45 +01:00
* [imagemagick](https://www.imagemagick.org/) (tested: 7.0 / 6.7)
2018-11-25 06:33:32 +01:00
* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2)
2018-11-24 11:00:07 +01:00
On a Debian system, install the packages: `build-essential cmake libcrypto++-dev
libmagick++-dev libxdg-basedir-dev`.
2018-11-27 05:46:45 +01:00
#### Compile
2018-11-24 11:00:07 +01:00
```SH
mkdir build
cd build
cmake ..
make
make install
```
2018-11-27 06:24:43 +01:00
##### cmake options
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
* One of:
* `-DWITH_DEB=YES` to generate a deb-package
* `-DWITH_RPM=YES` to generate an rpm-package
To generate a binary package, execute `make package`
2018-11-24 11:00:07 +01:00
## Contributing
Contributions are always welcome. You can submit them as pull requests or via
email to `tastytea`@`tastytea.de`.
2018-11-25 06:33:32 +01:00
## Contact
See https://tastytea.de/
2018-11-24 11:00:07 +01:00
## License & Copyright
```PLAIN
Copyright © 2018 tastytea <tastytea@tastytea.de>.
License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
```