Skip to content
Snippets Groups Projects
Commit 31e2e42b authored by pascoual's avatar pascoual
Browse files

Add claim tutorial on Writefreely template

parent e5effb7d
No related branches found
No related tags found
2 merge requests!20Add 'remember me' button,!17App template writefreely
...@@ -14,4 +14,55 @@ inspect_endpoint = {{ url_for("sso.oidc_userinfo", service_uuid=service.uuid, ...@@ -14,4 +14,55 @@ inspect_endpoint = {{ url_for("sso.oidc_userinfo", service_uuid=service.uuid,
auth_endpoint = {{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=False) }} auth_endpoint = {{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=False) }}
</pre> </pre>
<h3>Migrating accounts</h3>
<p>If you are running an existing WriteFreely server, you may import your existing accounts as claimable
profiles under Hiboo.
</p>
<p>Accounts are stored in the <i>users</i> table of the database. The following SQL query exports
userid, 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>
use writefreely;
select
username, password from users
into
outfile 'usersWF.csv'
fields terminated by ',';
</pre>
<p>Run the following command to import these profiles as unclaimed:</p>
<pre>
flask profile csv-unclaimed {{ service.uuid }} /var/lib/mysql/writefreely/usersWF.csv
</pre>
<p>
Click on "View profiles" on top of this page and click on "Export unclaimed profiles", save the csv file in /var/lib/mysql/writefreely/unclaimedWF.csv.
Use this script onWritefreely database:
</p>
<pre>
use writefreely;
CREATE TABLE tmp_hiboo (
service_client_id VARCHAR(36) NOT NULL,
profile_name VARCHAR(36) NOT NULL,
profile_uuid VARCHAR(36) NOT NULL,
PRIMARY KEY (profile_uuid)
);
LOAD DATA INFILE 'unclaimedWF.csv'
INTO TABLE tmp_hiboo
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
INSERT INTO oauth_users (user_id, remote_user_id, provider, client_id)
SELECT wf.id, h.profile_uuid, 'generic', h.service_client_id
FROM tmp_hiboo h
left join
users wf
ON h.profile_name = wf.username
</pre>
{% include "application_oidc.html" %} {% include "application_oidc.html" %}
\ No newline at end of file
...@@ -23,6 +23,14 @@ def list_for_service(service_uuid): ...@@ -23,6 +23,14 @@ def list_for_service(service_uuid):
service=service) service=service)
@blueprint.route("/unclaimedexport/service/<service_uuid>.csv")
@security.admin_required()
def unclaimed_export_for_service(service_uuid):
service = models.Service.query.get(service_uuid) or flask.abort(404)
return flask.render_template("profile_unclaimed_export.html", profiles=service.profiles,
service=service)
@blueprint.route("/details/<profile_uuid>") @blueprint.route("/details/<profile_uuid>")
@security.admin_required() @security.admin_required()
def details(profile_uuid): def details(profile_uuid):
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
{% endif %} {% endif %}
<th>{% trans %}Profile username{% endtrans %}</th> <th>{% trans %}Profile username{% endtrans %}</th>
<th>{% trans %}Owned by{% endtrans %}</th> <th>{% trans %}Owned by{% endtrans %}</th>
<th>{% trans %}UUID{% endtrans %}</th>
<th>{% trans %}Status{% endtrans %}</th> <th>{% trans %}Status{% endtrans %}</th>
<th>{% trans %}Created on{% endtrans %}</th> <th>{% trans %}Created on{% endtrans %}</th>
<th>{% trans %}Actions{% endtrans %}</th> <th>{% trans %}Actions{% endtrans %}</th>
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
<td>{{ profile.username }}</td> <td>{{ profile.username }}</td>
<td>-</td> <td>-</td>
{% endif %} {% endif %}
<td>{{ profile.uuid }}</td>
<td><span class="badge bg-{{ status[0] }}">{{ status[1] }}</span></td> <td><span class="badge bg-{{ status[0] }}">{{ status[1] }}</span></td>
<td>{{ profile.created_at.date() }}</td> <td>{{ profile.created_at.date() }}</td>
<td> <td>
...@@ -64,6 +66,7 @@ ...@@ -64,6 +66,7 @@
{% block actions %} {% block actions %}
{% if service %} {% if service %}
<a href="{{ url_for(".unclaimed_export_for_service", service_uuid=service.uuid) }}" class="btn btn-success" download>{% trans %}Export unclaimed profiles{% endtrans %}</a>
<a href="{{ url_for(".create_for", service_uuid=service.uuid) }}" class="btn btn-success">{% trans %}Create profile{% endtrans %}</a> <a href="{{ url_for(".create_for", service_uuid=service.uuid) }}" class="btn btn-success">{% trans %}Create profile{% endtrans %}</a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
service_client_id,profile_name,profile_uuid
{% for profile in profiles %}{% if profile.user_uuid %}{% else %}{{service.config["client_id"]}},{{ profile.username }},{{ profile.uuid }}
{% endif %}{% endfor %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment