From: Ivan Tashkinov Date: Mon, 8 Apr 2019 09:20:26 +0000 (+0300) Subject: [#923] Merge remote-tracking branch 'remotes/upstream/develop' into twitter_oauth X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=bffddf5e31c53d0603de387c61b6011f70785b97;p=akkoma [#923] Merge remote-tracking branch 'remotes/upstream/develop' into twitter_oauth # Conflicts: # docs/config.md # test/support/factory.ex --- bffddf5e31c53d0603de387c61b6011f70785b97 diff --cc config/config.exs index 05b164273,8a977ece5..a9539526d --- a/config/config.exs +++ b/config/config.exs @@@ -383,24 -389,15 +389,31 @@@ config :pleroma, :ldap base: System.get_env("LDAP_BASE") || "dc=example,dc=com", uid: System.get_env("LDAP_UID") || "cn" +oauth_consumer_strategies = String.split(System.get_env("OAUTH_CONSUMER_STRATEGIES") || "") + +ueberauth_providers = + for strategy <- oauth_consumer_strategies do + strategy_module_name = "Elixir.Ueberauth.Strategy.#{String.capitalize(strategy)}" + strategy_module = String.to_atom(strategy_module_name) + {String.to_atom(strategy), {strategy_module, [callback_params: ["state"]]}} + end + +config :ueberauth, + Ueberauth, + base_path: "/oauth", + providers: ueberauth_providers + +config :pleroma, :auth, oauth_consumer_strategies: oauth_consumer_strategies + config :pleroma, Pleroma.Mailer, adapter: Swoosh.Adapters.Sendmail + config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, path: "/api/pleroma/app_metrics" + + config :pleroma, Pleroma.ScheduledActivity, + daily_user_limit: 25, + total_user_limit: 300, + enabled: true + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --cc docs/config.md index 686f1f36b,ba0759e87..ed9b91363 --- a/docs/config.md +++ b/docs/config.md @@@ -390,11 -391,6 +391,17 @@@ config :auto_linker ] ``` ++## Pleroma.ScheduledActivity ++ ++* `daily_user_limit`: the number of scheduled activities a user is allowed to create in a single day (Default: `25`) ++* `total_user_limit`: the number of scheduled activities a user is allowed to create in total (Default: `300`) ++* `enabled`: whether scheduled activities are sent to the job queue to be executed ++ +## Pleroma.Web.Auth.Authenticator + +* `Pleroma.Web.Auth.PleromaAuthenticator`: default database authenticator +* `Pleroma.Web.Auth.LDAPAuthenticator`: LDAP authentication + ## :ldap Use LDAP for user authentication. When a user logs in to the Pleroma diff --cc lib/pleroma/web/endpoint.ex index 085f23159,6d9528c86..1633477c3 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@@ -76,10 -65,31 +76,30 @@@ defmodule Pleroma.Web.Endpoint d key: cookie_name, signing_salt: {Pleroma.Config, :get, [[__MODULE__, :signing_salt], "CqaoopA2"]}, http_only: true, - secure: - Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag), - extra: "SameSite=Strict" + secure: secure_cookies, + extra: same_site ) + # Note: the plug and its configuration is compile-time this can't be upstreamed yet + if proxies = Pleroma.Config.get([__MODULE__, :reverse_proxies]) do + plug(RemoteIp, proxies: proxies) + end + + defmodule Instrumenter do + use Prometheus.PhoenixInstrumenter + end + + defmodule PipelineInstrumenter do + use Prometheus.PlugPipelineInstrumenter + end + + defmodule MetricsExporter do + use Prometheus.PlugExporter + end + + plug(PipelineInstrumenter) + plug(MetricsExporter) + plug(Pleroma.Web.Router) @doc """ diff --cc lib/pleroma/web/oauth/oauth_controller.ex index 108303eb2,aac8f97fc..bee7084ad --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@@ -151,9 -149,10 +151,10 @@@ defmodule Pleroma.Web.OAuth.OAuthContro conn, %{"grant_type" => "password"} = params ) do - with {_, {:ok, %User{} = user}} <- {:get_user, Authenticator.get_user(conn)}, + with {_, {:ok, %User{} = user}} <- {:get_user, Authenticator.get_user(conn, params)}, %App{} = app <- get_app_from_request(conn, params), {:auth_active, true} <- {:auth_active, User.auth_active?(user)}, + {:user_active, true} <- {:user_active, !user.info.deactivated}, scopes <- oauth_scopes(params, app.scopes), [] <- scopes -- app.scopes, true <- Enum.any?(scopes), diff --cc mix.exs index 30931821f,ec0865c4f..26a03b70b --- a/mix.exs +++ b/mix.exs @@@ -103,8 -95,15 +103,15 @@@ defmodule Pleroma.Mixfile d git: "https://git.pleroma.social/pleroma/auto_linker.git", ref: "479dd343f4e563ff91215c8275f3b5c67e032850"}, {:pleroma_job_queue, "~> 0.2.0"}, + {:telemetry, "~> 0.3"}, + {:prometheus_ex, "~> 3.0"}, + {:prometheus_plugs, "~> 1.1"}, + {:prometheus_phoenix, "~> 1.2"}, + {:prometheus_ecto, "~> 1.4"}, + {:prometheus_process_collector, "~> 1.4"}, + {:recon, github: "ferd/recon", tag: "2.4.0"}, {:quack, "~> 0.1.1"} - ] + ] ++ oauth_deps end # Aliases are shortcuts or tasks specific to the current project. diff --cc test/support/factory.ex index 67953931b,608f8d46b..ea59912cf --- a/test/support/factory.ex +++ b/test/support/factory.ex @@@ -258,19 -268,11 +268,27 @@@ defmodule Pleroma.Factory d } end + def scheduled_activity_factory do + %Pleroma.ScheduledActivity{ + user: build(:user), + scheduled_at: NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(60), :millisecond), + params: build(:note) |> Map.from_struct() |> Map.get(:data) + } + end ++ + def registration_factory do + user = insert(:user) + + %Pleroma.Registration{ + user: user, + provider: "twitter", + uid: "171799000", + info: %{ + "name" => "John Doe", + "email" => "john@doe.com", + "nickname" => "johndoe", + "description" => "My bio" + } + } + end end