BigW Consortium Gitlab

libravatar.md 2.87 KB
Newer Older
1 2
# Use Libravatar service with GitLab

3
GitLab by default supports [Gravatar](https://gravatar.com) avatar service.
4
Libravatar is a service which delivers your avatar (profile picture) to other websites and their API is
5
[heavily based on gravatar](https://wiki.libravatar.org/api/).
6 7 8 9 10 11 12 13 14 15 16 17 18

This means that it is not complicated to switch to Libravatar avatar service or even self hosted Libravatar server.

# Configuration

In [gitlab.yml gravatar section](https://gitlab.com/gitlab-org/gitlab-ce/blob/672bd3902d86b78d730cea809fce312ec49d39d7/config/gitlab.yml.example#L122) set
the configuration options as follows:

## For HTTP

```yml
  gravatar:
    enabled: true
19
    # gravatar URLs: possible placeholders: %{hash} %{size} %{email}
20 21 22 23 24 25 26 27
    plain_url: "http://cdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```

## For HTTPS

```yml
  gravatar:
    enabled: true
28
    # gravatar URLs: possible placeholders: %{hash} %{size} %{email}
29 30 31 32 33
    ssl_url: "https://seccdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```

## Self-hosted

34
If you are [running your own libravatar service](https://wiki.libravatar.org/running_your_own/) the URL will be different in the configuration
35
but the important part is to provide the same placeholders so GitLab can parse the URL correctly.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

For example, you host a service on `http://libravatar.example.com` the `plain_url` you need to supply in `gitlab.yml` is

`http://libravatar.example.com/avatar/%{hash}?s=%{size}&d=identicon`


## Omnibus-gitlab example

In `/etc/gitlab/gitlab.rb`:

#### For http

```ruby
gitlab_rails['gravatar_enabled'] = true
gitlab_rails['gravatar_plain_url'] = "http://cdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```

#### For https

```ruby
gitlab_rails['gravatar_enabled'] = true
gitlab_rails['gravatar_ssl_url'] = "https://seccdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```


Run `sudo gitlab-ctl reconfigure` for changes to take effect.


## Default URL for missing images

66
[Libravatar supports different sets](https://wiki.libravatar.org/api/) of `missing images` for emails not found on the Libravatar service.
67

68 69
In order to use a different set other than `identicon`, replace `&d=identicon` portion of the URL with another supported set.
For example, you can use `retro` set in which case the URL would look like: `plain_url: "http://cdn.libravatar.org/avatar/%{hash}?s=%{size}&d=retro"`
70 71 72 73 74 75 76 77 78 79 80 81 82


## Usage examples

#### For Microsoft Office 365

If your users are Office 365-users, the "GetPersonaPhoto" service can be used. Note that this service requires login, so this use case is
most useful in a corporate installation, where all users have access to Office 365.

```ruby
gitlab_rails['gravatar_plain_url'] = 'http://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=%{email}&size=HR120x120'
gitlab_rails['gravatar_ssl_url'] = 'https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=%{email}&size=HR120x120'
```