Add initial docs page, improve adding domains
Signed-off-by: Marcin Mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
c2c7c23aab
commit
182e0b58da
7 changed files with 56 additions and 10 deletions
|
@ -1061,6 +1061,18 @@
|
|||
suggestions: [
|
||||
"en"
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :multitenancy,
|
||||
type: :map,
|
||||
description: "Multitenancy support",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Enables allowing multiple Webfinger domains"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3466,5 +3478,5 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# How to serve multiple domains for Pleroma user identifiers
|
||||
|
||||
It is possible to use multiple domains for WebFinger identifiers. If configured, users can select from the available domains during registration. Domains can be set by instance administrator and can be marked as either public (everyone can choose it) or private (only available when admin creates a user)
|
||||
|
||||
## Configuring
|
||||
|
||||
### Configuring Pleroma
|
||||
|
||||
To enable using multiple domains, append the following to your `prod.secret.exs` or `dev.secret.exs`:
|
||||
```elixir
|
||||
config :pleroma, :instance, :multitenancy, enabled: true
|
||||
```
|
||||
|
||||
Creating, updating and deleting domains is available from the admin API.
|
||||
|
||||
### Configuring WebFinger domains
|
||||
|
||||
If you recall how webfinger queries work, the first step is to query `https://example.org/.well-known/host-meta`, which will contain an URL template.
|
||||
|
||||
Therefore, the easiest way to configure the additional domains is to redirect `/.well-known/host-meta` to the domain used by Pleroma.
|
||||
|
||||
With nginx, it would be as simple as adding:
|
||||
|
||||
```nginx
|
||||
location = /.well-known/host-meta {
|
||||
return 301 https://pleroma.example.org$request_uri;
|
||||
}
|
||||
```
|
||||
|
||||
in the additional domain's server block.
|
|
@ -19,11 +19,13 @@ def changeset(%__MODULE__{} = domain, params \\ %{}) do
|
|||
domain
|
||||
|> cast(params, [:domain, :public])
|
||||
|> validate_required([:domain])
|
||||
|> update_change(:domain, &String.downcase/1)
|
||||
|> unique_constraint(:domain)
|
||||
end
|
||||
|
||||
def update_changeset(%__MODULE__{} = domain, params \\ %{}) do
|
||||
domain
|
||||
|> cast(params, [:domain])
|
||||
|> cast(params, [:public])
|
||||
end
|
||||
|
||||
def get(id), do: Repo.get(__MODULE__, id)
|
||||
|
|
|
@ -37,11 +37,13 @@ def index(conn, _) do
|
|||
end
|
||||
|
||||
def create(%{body_params: params} = conn, _) do
|
||||
domain =
|
||||
params
|
||||
|> Domain.create()
|
||||
|
||||
render(conn, "show.json", domain: domain)
|
||||
with {:domain_not_used, true} <-
|
||||
{:domain_not_used, params[:domain] !== Pleroma.Web.WebFinger.domain()},
|
||||
{:domain, domain} <- Domain.create(params) do
|
||||
render(conn, "show.json", domain: domain)
|
||||
else
|
||||
{:domain_not_used, false} -> {:error, :invalid_domain}
|
||||
end
|
||||
end
|
||||
|
||||
def update(%{body_params: params} = conn, %{id: id}) do
|
||||
|
|
|
@ -147,7 +147,7 @@ def fields_limits do
|
|||
end
|
||||
|
||||
defp multitenancy do
|
||||
enabled = Config.get([:multitenancy, :enabled])
|
||||
enabled = Config.get([:instance, :multitenancy, :enabled])
|
||||
|
||||
if enabled do
|
||||
domains =
|
||||
|
|
|
@ -102,7 +102,7 @@ defp get_subject(%User{nickname: nickname}) do
|
|||
end
|
||||
end
|
||||
|
||||
defp domain do
|
||||
def domain do
|
||||
Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule Pleroma.Repo.Migrations.CreateDomains do
|
|||
|
||||
def change do
|
||||
create_if_not_exists table(:domains) do
|
||||
add(:domain, :string)
|
||||
add(:domain, :citext)
|
||||
add(:public, :boolean)
|
||||
|
||||
timestamps()
|
||||
|
|
Loading…
Reference in a new issue