[#468] User UI for OAuth permissions restriction. Standardized storage format for...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 13 Feb 2019 21:29:29 +0000 (00:29 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 13 Feb 2019 21:29:29 +0000 (00:29 +0300)
18 files changed:
lib/pleroma/plugs/oauth_scopes_plug.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/oauth.ex
lib/pleroma/web/oauth/app.ex
lib/pleroma/web/oauth/authorization.ex
lib/pleroma/web/oauth/oauth_controller.ex
lib/pleroma/web/oauth/token.ex
lib/pleroma/web/templates/layout/app.html.eex
lib/pleroma/web/templates/o_auth/o_auth/show.html.eex
mix.lock
priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs [moved from priv/repo/migrations/20190208131753_add_scope_to_o_auth_entities.exs with 53% similarity]
priv/repo/migrations/20190209123318_data_migration_populate_o_auth_scopes.exs [moved from priv/repo/migrations/20190209123318_data_migration_populate_o_auth_scope.exs with 85% similarity]
priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs [new file with mode: 0644]
test/integration/mastodon_websocket_test.exs
test/support/factory.ex
test/web/oauth/authorization_test.exs
test/web/oauth/oauth_controller_test.exs
test/web/oauth/token_test.exs

index a16adb00439ffa0fdf9e5791862d88e6ae560adf..a81e298307a7963a9785d292e2cfcef8c1da957d 100644 (file)
@@ -4,7 +4,6 @@
 
 defmodule Pleroma.Plugs.OAuthScopesPlug do
   import Plug.Conn
-  alias Pleroma.Web.OAuth
 
   @behaviour Plug
 
@@ -12,7 +11,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlug do
 
   def call(%Plug.Conn{assigns: assigns} = conn, %{required_scopes: required_scopes}) do
     token = assigns[:token]
-    granted_scopes = token && OAuth.parse_scopes(token.scope)
+    granted_scopes = token && token.scopes
 
     if is_nil(token) || required_scopes -- granted_scopes == [] do
       conn
index dbe7c25542b061601211d8ae3c50d246ddc9510a..59f472e91b66db83d63c2b20f926691022ba55ba 100644 (file)
@@ -19,6 +19,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.OAuth
   alias Pleroma.Web.OAuth.{Authorization, Token, App}
   alias Pleroma.Web.MediaProxy
 
@@ -31,7 +32,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   action_fallback(:errors)
 
   def create_app(conn, params) do
-    with cs <- App.register_changeset(%App{}, params),
+    scopes = OAuth.parse_scopes(params["scope"] || params["scopes"])
+    app_attrs = params |> Map.drop(["scope", "scopes"]) |> Map.put("scopes", scopes)
+
+    with cs <- App.register_changeset(%App{}, app_attrs),
          false <- cs.changes[:client_name] == @local_mastodon_name,
          {:ok, app} <- Repo.insert(cs) do
       res = %{
@@ -1162,7 +1166,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       {:ok, app}
     else
       _e ->
-        cs = App.register_changeset(%App{}, Map.put(find_attrs, :scopes, "read,write,follow"))
+        cs =
+          App.register_changeset(
+            %App{},
+            Map.put(find_attrs, :scopes, ["read", "write", "follow"])
+          )
 
         Repo.insert(cs)
     end
index 44b83433e847e1bc6c15e31857324c7ba397cbe1..761b80fdeb451d365c928f7d65c7e136a8e3085f 100644 (file)
@@ -3,9 +3,22 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.OAuth do
-  def parse_scopes(scopes) do
+  def parse_scopes(nil) do
+    nil
+  end
+
+  def parse_scopes(scopes) when is_list(scopes) do
     scopes
-    |> to_string()
-    |> String.split([" ", ","])
+  end
+
+  def parse_scopes(scopes) do
+    scopes =
+      scopes
+      |> to_string()
+      |> String.trim()
+
+    if scopes == "",
+      do: [],
+      else: String.split(scopes, [" ", ","])
   end
 end
index 967ac04b5d378a366dc65372aae0d436d2b36e1f..c04626a73835c1b4e38cf91312fc010db57128f8 100644 (file)
@@ -9,7 +9,7 @@ defmodule Pleroma.Web.OAuth.App do
   schema "apps" do
     field(:client_name, :string)
     field(:redirect_uris, :string)
-    field(:scopes, :string)
+    field(:scopes, {:array, :string}, default: [])
     field(:website, :string)
     field(:client_id, :string)
     field(:client_secret, :string)
index 0fbaa902b408ecc8f86a6fd91b8c84ee8a7f8bc7..c5b7ec9a5628499719103909f7f81aa7b2e8b034 100644 (file)
@@ -6,14 +6,13 @@ defmodule Pleroma.Web.OAuth.Authorization do
   use Ecto.Schema
 
   alias Pleroma.{User, Repo}
-  alias Pleroma.Web.OAuth
   alias Pleroma.Web.OAuth.{Authorization, App}
 
   import Ecto.{Changeset, Query}
 
   schema "oauth_authorizations" do
     field(:token, :string)
-    field(:scope, :string)
+    field(:scopes, {:array, :string}, default: [])
     field(:valid_until, :naive_datetime)
     field(:used, :boolean, default: false)
     belongs_to(:user, Pleroma.User, type: Pleroma.FlakeId)
@@ -22,8 +21,8 @@ defmodule Pleroma.Web.OAuth.Authorization do
     timestamps()
   end
 
-  def create_authorization(%App{} = app, %User{} = user, scope \\ nil) do
-    scopes = OAuth.parse_scopes(scope || app.scopes)
+  def create_authorization(%App{} = app, %User{} = user, scopes \\ nil) do
+    scopes = scopes || app.scopes
     token = :crypto.strong_rand_bytes(32) |> Base.url_encode64()
 
     authorization = %Authorization{
@@ -31,7 +30,7 @@ defmodule Pleroma.Web.OAuth.Authorization do
       used: false,
       user_id: user.id,
       app_id: app.id,
-      scope: Enum.join(scopes, " "),
+      scopes: scopes,
       valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), 60 * 10)
     }
 
index 15345d4bac9f55899fd7221a519e55fb6403f4eb..f00d5293d25190fb62788217d30ba0dc88f44eda 100644 (file)
@@ -5,6 +5,7 @@
 defmodule Pleroma.Web.OAuth.OAuthController do
   use Pleroma.Web, :controller
 
+  alias Pleroma.Web.OAuth
   alias Pleroma.Web.OAuth.{Authorization, Token, App}
   alias Pleroma.{Repo, User}
   alias Comeonin.Pbkdf2
@@ -18,7 +19,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
     render(conn, "show.html", %{
       response_type: params["response_type"],
       client_id: params["client_id"],
-      scope: params["scope"],
+      scopes: scopes(params) || [],
       redirect_uri: params["redirect_uri"],
       state: params["state"]
     })
@@ -38,7 +39,10 @@ defmodule Pleroma.Web.OAuth.OAuthController do
          {:auth_active, true} <- {:auth_active, User.auth_active?(user)},
          %App{} = app <- Repo.get_by(App, client_id: client_id),
          true <- redirect_uri in String.split(app.redirect_uris),
-         {:ok, auth} <- Authorization.create_authorization(app, user, params["scope"]) do
+         scopes <- scopes(params) || app.scopes,
+         [] <- scopes -- app.scopes,
+         true <- Enum.any?(scopes),
+         {:ok, auth} <- Authorization.create_authorization(app, user, scopes) do
       # Special case: Local MastodonFE.
       redirect_uri =
         if redirect_uri == "." do
@@ -94,7 +98,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
         refresh_token: token.refresh_token,
         created_at: DateTime.to_unix(inserted_at),
         expires_in: 60 * 10,
-        scope: token.scope
+        scope: Enum.join(token.scopes)
       }
 
       json(conn, response)
@@ -113,14 +117,15 @@ defmodule Pleroma.Web.OAuth.OAuthController do
          %User{} = user <- User.get_by_nickname_or_email(name),
          true <- Pbkdf2.checkpw(password, user.password_hash),
          {:auth_active, true} <- {:auth_active, User.auth_active?(user)},
-         {:ok, auth} <- Authorization.create_authorization(app, user, params["scope"]),
+         scopes <- scopes(params) || app.scopes,
+         {:ok, auth} <- Authorization.create_authorization(app, user, scopes),
          {:ok, token} <- Token.exchange_token(app, auth) do
       response = %{
         token_type: "Bearer",
         access_token: token.token,
         refresh_token: token.refresh_token,
         expires_in: 60 * 10,
-        scope: token.scope
+        scope: Enum.join(token.scopes, " ")
       }
 
       json(conn, response)
@@ -192,4 +197,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
       nil
     end
   end
+
+  defp scopes(params),
+    do: OAuth.parse_scopes(params["scopes"] || params["scope"])
 end
index 61f43ed5a9aba7e2c13624bd42e8d7e2beed05f9..1fae5ed3a6018b222cae78ae6f768024bdd4051b 100644 (file)
@@ -8,13 +8,12 @@ defmodule Pleroma.Web.OAuth.Token do
   import Ecto.Query
 
   alias Pleroma.{User, Repo}
-  alias Pleroma.Web.OAuth
   alias Pleroma.Web.OAuth.{Token, App, Authorization}
 
   schema "oauth_tokens" do
     field(:token, :string)
     field(:refresh_token, :string)
-    field(:scope, :string)
+    field(:scopes, {:array, :string}, default: [])
     field(:valid_until, :naive_datetime)
     belongs_to(:user, Pleroma.User, type: Pleroma.FlakeId)
     belongs_to(:app, App)
@@ -25,19 +24,19 @@ defmodule Pleroma.Web.OAuth.Token do
   def exchange_token(app, auth) do
     with {:ok, auth} <- Authorization.use_token(auth),
          true <- auth.app_id == app.id do
-      create_token(app, Repo.get(User, auth.user_id), auth.scope)
+      create_token(app, Repo.get(User, auth.user_id), auth.scopes)
     end
   end
 
-  def create_token(%App{} = app, %User{} = user, scope \\ nil) do
-    scopes = OAuth.parse_scopes(scope || app.scopes)
+  def create_token(%App{} = app, %User{} = user, scopes \\ nil) do
+    scopes = scopes || app.scopes
     token = :crypto.strong_rand_bytes(32) |> Base.url_encode64()
     refresh_token = :crypto.strong_rand_bytes(32) |> Base.url_encode64()
 
     token = %Token{
       token: token,
       refresh_token: refresh_token,
-      scope: Enum.join(scopes, " "),
+      scopes: scopes,
       user_id: user.id,
       app_id: app.id,
       valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), 60 * 10)
index 8dd3284d63e147151c7e16cd374062ca56ceda4f..f944cbc262aa2d8859c158036fb3cac77dda3808 100644 (file)
         border-bottom: 2px solid #4b8ed8;
       }
 
+      input[type="checkbox"] {
+        width: auto;
+      }
+
       button {
         box-sizing: border-box;
         width: 100%;
index e1c0af975c8af8bb9358d3674f0f01c96161b473..1ecb5b4444d931b0b0c18ddf07da79e69680472d 100644 (file)
@@ -5,12 +5,20 @@
 <%= label f, :name, "Name or email" %>
 <%= text_input f, :name %>
 <br>
+<br>
 <%= label f, :password, "Password" %>
 <%= password_input f, :password %>
 <br>
-<%= label f, :scope, "Scopes" %>
-<%= text_input f, :scope, value: @scope %>
 <br>
+
+<%= label f, :scope, "Permissions" %>
+<br>
+<%= for scope <- @scopes do %>
+  <%= checkbox f, :"scopes_#{scope}", hidden_input: false, value: scope, checked_value: scope, name: "authorization[scopes][]" %>
+  <%= label f, :"scopes_#{scope}", String.capitalize(scope) %>
+  <br>
+<% end %>
+
 <%= hidden_input f, :client_id, value: @client_id %>
 <%= hidden_input f, :response_type, value: @response_type %>
 <%= hidden_input f, :redirect_uri, value: @redirect_uri %>
index 31725a47725a5faaa8c54517760b0ee0ac0103a0..02748f54105930f8b2b69a3cd568542bbf337e32 100644 (file)
--- a/mix.lock
+++ b/mix.lock
@@ -20,8 +20,8 @@
   "ex_aws_s3": {:hex, :ex_aws_s3, "2.0.1", "9e09366e77f25d3d88c5393824e613344631be8db0d1839faca49686e99b6704", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"},
   "ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
   "ex_machina": {:hex, :ex_machina, "2.2.0", "fec496331e04fc2db2a1a24fe317c12c0c4a50d2beb8ebb3531ed1f0d84be0ed", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
-  "floki": {:hex, :floki, "0.20.4", "be42ac911fece24b4c72f3b5846774b6e61b83fe685c2fc9d62093277fb3bc86", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}, {:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"},
   "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]},
+  "floki": {:hex, :floki, "0.20.4", "be42ac911fece24b4c72f3b5846774b6e61b83fe685c2fc9d62093277fb3bc86", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}, {:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"},
   "gen_smtp": {:hex, :gen_smtp, "0.13.0", "11f08504c4bdd831dc520b8f84a1dce5ce624474a797394e7aafd3c29f5dcd25", [:rebar3], [], "hexpm"},
   "gettext": {:hex, :gettext, "0.15.0", "40a2b8ce33a80ced7727e36768499fc9286881c43ebafccae6bab731e2b2b8ce", [:mix], [], "hexpm"},
   "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
@@ -45,9 +45,9 @@
   "pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [:mix], [], "hexpm"},
   "phoenix": {:git, "https://github.com/phoenixframework/phoenix.git", "ea22dc50b574178a300ecd19253443960407df93", [branch: "v1.4"]},
   "phoenix_ecto": {:hex, :phoenix_ecto, "3.3.0", "702f6e164512853d29f9d20763493f2b3bcfcb44f118af2bc37bb95d0801b480", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
-  "phoenix_html": {:hex, :phoenix_html, "2.11.2", "86ebd768258ba60a27f5578bec83095bdb93485d646fc4111db8844c316602d6", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
+  "phoenix_html": {:hex, :phoenix_html, "2.13.1", "fa8f034b5328e2dfa0e4131b5569379003f34bc1fafdaa84985b0b9d2f12e68b", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
   "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
-  "plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
+  "plug": {:hex, :plug, "1.7.2", "d7b7db7fbd755e8283b6c0a50be71ec0a3d67d9213d74422d9372effc8e87fd1", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
   "plug_cowboy": {:hex, :plug_cowboy, "1.0.0", "2e2a7d3409746d335f451218b8bb0858301c3de6d668c3052716c909936eb57a", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
   "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
   "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
similarity index 53%
rename from priv/repo/migrations/20190208131753_add_scope_to_o_auth_entities.exs
rename to priv/repo/migrations/20190208131753_add_scopes_to_o_auth_entities.exs
index 809e9ab2215f98c31d16aabc4f26bebec476c36e..4efbebc4da40e40c2ad6d3d606284a50b08112fd 100644 (file)
@@ -1,10 +1,10 @@
-defmodule Pleroma.Repo.Migrations.AddScopeToOAuthEntities do
+defmodule Pleroma.Repo.Migrations.AddScopeSToOAuthEntities do
   use Ecto.Migration
 
   def change do
     for t <- [:oauth_authorizations, :oauth_tokens] do
       alter table(t) do
-        add :scope, :string
+        add :scopes, {:array, :string}, default: [], null: false
       end
     end
   end
similarity index 85%
rename from priv/repo/migrations/20190209123318_data_migration_populate_o_auth_scope.exs
rename to priv/repo/migrations/20190209123318_data_migration_populate_o_auth_scopes.exs
index 722cd6cf9b4e81cc53d36560d8c0a997a028e7c5..30b10f56f61e2430a25e848b363293fa7982c9d7 100644 (file)
@@ -1,4 +1,4 @@
-defmodule Pleroma.Repo.Migrations.DataMigrationPopulateOAuthScope do
+defmodule Pleroma.Repo.Migrations.DataMigrationPopulateOAuthScopes do
   use Ecto.Migration
 
   require Ecto.Query
@@ -11,16 +11,15 @@ defmodule Pleroma.Repo.Migrations.DataMigrationPopulateOAuthScope do
   def up do
     for app <- Repo.all(Query.from(app in App)) do
       scopes = OAuth.parse_scopes(app.scopes)
-      scope = Enum.join(scopes, " ")
 
       Repo.update_all(
         Query.from(auth in Authorization, where: auth.app_id == ^app.id),
-        set: [scope: scope]
+        set: [scopes: scopes]
       )
 
       Repo.update_all(
         Query.from(token in Token, where: token.app_id == ^app.id),
-        set: [scope: scope]
+        set: [scopes: scopes]
       )
     end
   end
diff --git a/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs b/priv/repo/migrations/20190213185503_change_apps_scopes_to_varchar_array.exs
new file mode 100644 (file)
index 0000000..72decd4
--- /dev/null
@@ -0,0 +1,17 @@
+defmodule Pleroma.Repo.Migrations.ChangeAppsScopesToVarcharArray do
+  use Ecto.Migration
+
+  @alter_apps_scopes "ALTER TABLE apps ALTER COLUMN scopes"
+
+  def up do
+    execute "#{@alter_apps_scopes} TYPE varchar(255)[] USING string_to_array(scopes, ',')::varchar(255)[];"
+    execute "#{@alter_apps_scopes} SET DEFAULT ARRAY[]::character varying[];"
+    execute "#{@alter_apps_scopes} SET NOT NULL;"
+  end
+
+  def down do
+    execute "#{@alter_apps_scopes} DROP NOT NULL;"
+    execute "#{@alter_apps_scopes} DROP DEFAULT;"
+    execute "#{@alter_apps_scopes} TYPE varchar(255) USING array_to_string(scopes, ',')::varchar(255);"
+  end
+end
index 2e385f5adbacb3070063c9e121f4af439f82b8e8..0c513b6e75feab22454ee2df23a5afbef7d37dae 100644 (file)
@@ -80,7 +80,7 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
         Pleroma.Repo.insert(
           OAuth.App.register_changeset(%OAuth.App{}, %{
             client_name: "client",
-            scopes: "scope",
+            scopes: ["scope"],
             redirect_uris: "url"
           })
         )
index 0c21093cef5c3f7c4a8082d29a7f2d49623ffa66..eaa6f0ce289d3f4f74574acc85334a819a34ad92 100644 (file)
@@ -214,7 +214,7 @@ defmodule Pleroma.Factory do
     %Pleroma.Web.OAuth.App{
       client_name: "Some client",
       redirect_uris: "https://example.com/callback",
-      scopes: "read",
+      scopes: ["read"],
       website: "https://example.com",
       client_id: "aaabbb==",
       client_secret: "aaa;/&bbb"
index 3b1ddada81e70fcce978833e8782d4b8da472aae..68db1ceb0ede5200ac1780654268acc6e3b39e8d 100644 (file)
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.OAuth.AuthorizationTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )
@@ -32,7 +32,7 @@ defmodule Pleroma.Web.OAuth.AuthorizationTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.OAuth.AuthorizationTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )
index e0d3cb55f916d0ccafc777457251028db12e90bf..74d512c7f7565ecab92a7ea3ddf4d0823ee0c97d 100644 (file)
@@ -21,6 +21,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
           "password" => "test",
           "client_id" => app.client_id,
           "redirect_uri" => app.redirect_uris,
+          "scope" => Enum.join(app.scopes, " "),
           "state" => "statepassed"
         }
       })
index 9a241d61a04d20806df97538430a0046042d65e7..63a7eb3ae75366218f1d303887e1ee979131bda0 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.OAuth.TokenTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )
@@ -39,7 +39,7 @@ defmodule Pleroma.Web.OAuth.TokenTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client1",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.OAuth.TokenTest do
       Repo.insert(
         App.register_changeset(%App{}, %{
           client_name: "client2",
-          scopes: "scope",
+          scopes: ["scope"],
           redirect_uris: "url"
         })
       )