[#2353] Virtually never-expiring OAuth tokens (new and already issued ones).
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 17 Dec 2020 17:49:00 +0000 (20:49 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 17 Dec 2020 17:49:00 +0000 (20:49 +0300)
config/config.exs
priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs [new file with mode: 0644]

index 98c87a4f9f07fe5925f637162804fe42a7f58f4d..3ccb6a3f5bdadf04a5661a7416a8892ce5a4e317 100644 (file)
@@ -648,7 +648,7 @@ config :pleroma, :email_notifications,
   }
 
 config :pleroma, :oauth2,
-  token_expires_in: 3600 * 24 * 30,
+  token_expires_in: 3600 * 24 * 365 * 100,
   issue_new_refresh_token: true,
   clean_expired_tokens: false
 
diff --git a/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
new file mode 100644 (file)
index 0000000..560cc74
--- /dev/null
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.DataMigrationProlongOAuthTokensValidUntil do
+  use Ecto.Migration
+
+  def up do
+    expires_in = Pleroma.Config.get!([:oauth2, :token_expires_in])
+    valid_until = NaiveDateTime.add(NaiveDateTime.utc_now(), expires_in, :second)
+    execute("update oauth_tokens set valid_until = '#{valid_until}'")
+  end
+
+  def down do
+    :noop
+  end
+end