From 7dc76094536b2b2a6af3c4f3e85d92351578e16c Mon Sep 17 00:00:00 2001
From: kaiyou <pierre@jaury.eu>
Date: Tue, 31 Mar 2020 15:48:11 +0200
Subject: [PATCH] Add migration instructions for Seafile

---
 .../templates/application_seafile.html        | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/hiboo/application/templates/application_seafile.html b/hiboo/application/templates/application_seafile.html
index e5f290f..b59e7d5 100644
--- a/hiboo/application/templates/application_seafile.html
+++ b/hiboo/application/templates/application_seafile.html
@@ -20,4 +20,33 @@ OAUTH_ATTRIBUTE_MAP = {
 }
 </pre>
 
+<h3>Migrating accounts</h3>
+<p>If you are running an existing Seafile server, you may import your existing accounts as claimable
+    profiles under Hiboo.
+</p>
+<p>Accounts are stored in the <i>EmailUser</i> table of the <i>ccnet_db</i> database. However, we recommend
+    that profiles be named after the username instead of the email address. The following SQL query exports
+    username, password hash, and user email as alternate claim to a CSV file. It dynamically converts the password
+    to use a proper crypt context hash identifier, so that Hiboo will recognize the hash.
+</p>
+<pre>
+    select
+        profile.nickname,
+        user.email,
+        CONCAT('$pbkdf2-sha256$10000$', SUBSTRING(TO_BASE64(UNHEX(SUBSTRING(user.passwd,20,64))),1,43), '$', SUBSTRING(TO_BASE64(UNHEX(SUBSTRING(user.passwd,85,64))),1,43)) as password
+    from
+        ccnet_db.EmailUser as user
+    left join
+        seahub_db.profile_profile as profile
+    on
+        profile.user=user.email
+    into
+        outfile '/tmp/users.csv'
+        fields terminated by ',';
+</pre>
+<p>Please grab the exported CSV file, copy it next to Hiboo, and run the following command to import these profiles as unclaimed.</p>
+<pre>
+    flask profile csv-unclaimed {{ service.uuid }} /tmp/users.csv
+</pre>
+
 {% include "application_oidc.html" %}
\ No newline at end of file
-- 
GitLab