aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/oauth/scopes.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-09-08 15:00:03 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-09-08 15:00:03 +0300
commitb63faf9819c2c49d2e9b63e7f37136eb03d8b4e8 (patch)
treed25b45e591b65becf796c08b6004e23c1be67a3c /lib/pleroma/web/oauth/scopes.ex
parentc45013df8e53334bcc1afb8cd1df673c290037ee (diff)
downloadpleroma-b63faf9819c2c49d2e9b63e7f37136eb03d8b4e8.tar.gz
[#1234] Mastodon 2.4.3 hierarchical scopes initial support (WIP).
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