2019-02-09 14:09:08 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.OAuth do
|
2019-02-21 15:55:19 +00:00
|
|
|
@authenticator Application.get_env(
|
|
|
|
:pleroma,
|
|
|
|
Pleroma.Web.AuthenticatorAdapter,
|
|
|
|
Pleroma.Web.Authenticator
|
|
|
|
)
|
|
|
|
|
|
|
|
def authenticator, do: @authenticator
|
|
|
|
|
2019-02-15 16:54:37 +00:00
|
|
|
def parse_scopes(scopes, _default) when is_list(scopes) do
|
|
|
|
Enum.filter(scopes, &(&1 not in [nil, ""]))
|
2019-02-13 21:29:29 +00:00
|
|
|
end
|
|
|
|
|
2019-02-14 14:03:19 +00:00
|
|
|
def parse_scopes(scopes, default) when is_binary(scopes) do
|
2019-02-09 14:09:08 +00:00
|
|
|
scopes
|
2019-02-15 16:54:37 +00:00
|
|
|
|> String.trim()
|
2019-02-14 14:03:19 +00:00
|
|
|
|> String.split(~r/[\s,]+/)
|
|
|
|
|> parse_scopes(default)
|
2019-02-13 21:29:29 +00:00
|
|
|
end
|
|
|
|
|
2019-02-14 14:03:19 +00:00
|
|
|
def parse_scopes(_, default) do
|
|
|
|
default
|
2019-02-09 14:09:08 +00:00
|
|
|
end
|
|
|
|
end
|