aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/oauth/scopes.ex
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2019-10-07 02:14:45 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2019-10-07 02:14:45 +0000
commitb4f3c16885a489c40de82e5ef321caafa4b10c81 (patch)
treee81e3d7ba6882b31bd18c221f872049af73e44f2 /lib/pleroma/web/oauth/scopes.ex
parent25cffffaf1685ef02cd318bdbd99bb325d295458 (diff)
parentb93856874de673f1c05c557ad482d4480ca7e0a7 (diff)
downloadpleroma-b4f3c16885a489c40de82e5ef321caafa4b10c81.tar.gz
Merge branch '1234-mastodon-2-4-3-oauth-scopes' into 'develop'
[#1234] Mastodon 2.4.3 hierarchical OAuth scopes Closes #1234 See merge request pleroma/pleroma!1643
Diffstat (limited to 'lib/pleroma/web/oauth/scopes.ex')
-rw-r--r--lib/pleroma/web/oauth/scopes.ex14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/pleroma/web/oauth/scopes.ex b/lib/pleroma/web/oauth/scopes.ex
index ad9dfb260..48bd14407 100644
--- a/lib/pleroma/web/oauth/scopes.ex
+++ b/lib/pleroma/web/oauth/scopes.ex
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.OAuth.Scopes do
"""
@doc """
- Fetch scopes from requiest params.
+ Fetch scopes from request params.
Note: `scopes` is used by Mastodon — supporting it but sticking to
OAuth's standard `scope` wherever we control it
@@ -53,14 +53,14 @@ defmodule Pleroma.Web.OAuth.Scopes do
@doc """
Validates scopes.
"""
- @spec validates(list() | nil, list()) ::
+ @spec validate(list() | nil, list()) ::
{:ok, list()} | {:error, :missing_scopes | :unsupported_scopes}
- def validates([], _app_scopes), do: {:error, :missing_scopes}
- def validates(nil, _app_scopes), do: {:error, :missing_scopes}
+ def validate([], _app_scopes), do: {:error, :missing_scopes}
+ def validate(nil, _app_scopes), do: {:error, :missing_scopes}
- def validates(scopes, app_scopes) do
- case scopes -- app_scopes do
- [] -> {:ok, scopes}
+ def validate(scopes, app_scopes) do
+ case Pleroma.Plugs.OAuthScopesPlug.filter_descendants(scopes, app_scopes) do
+ ^scopes -> {:ok, scopes}
_ -> {:error, :unsupported_scopes}
end
end