defmodule Nugitea.Auth do@moduledoc """The access-control seam: the HTTP, SSH and GraphQL front ends ask thisrather than deciding themselves. The implementation is the `:authorizer`app setting; the default, `Nugitea.Auth.Directory`, follows repovisibility and grants in accounts.json. `AllowAll` permits everything."""@callback allow_pull?(user :: integer | nil, repo :: String.t()) :: boolean@callback allow_push?(user :: integer | nil, repo :: String.t()) :: booleandef allow?("upload-pack", user, repo), do: impl().allow_pull?(user, repo)def allow?("receive-pack", user, repo), do: impl().allow_push?(user, repo)def allow_pull?(repo), do: impl().allow_pull?(nil, repo)defp impl, do: Application.get_env(:nugitea, :authorizer, Nugitea.Auth.Directory)enddefmodule Nugitea.Auth.AllowAll do@moduledoc "Permits every pull and push."@behaviour Nugitea.Auth@impl truedef allow_pull?(_user, _repo), do: true@impl truedef allow_push?(_user, _repo), do: trueend