From b2ef1a09f4edd06bb431fc9a2c08366ec23a2f8a Mon Sep 17 00:00:00 2001 From: kaiyou <pierre@jaury.eu> Date: Thu, 11 Jun 2020 11:09:21 +0200 Subject: [PATCH] Add a peertube application template --- hiboo/application/social.py | 34 ++++++++++++++++++- .../templates/application_peertube.html | 23 +++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 hiboo/application/templates/application_peertube.html diff --git a/hiboo/application/social.py b/hiboo/application/social.py index 51526966..cdbd9999 100644 --- a/hiboo/application/social.py +++ b/hiboo/application/social.py @@ -58,8 +58,10 @@ class SynapseApplication(base.SAMLApplication): obj=service, application_uri=service.config.get("application_uri") ) + + @register("writefreely") -class GitlabApplication(base.OIDCApplication): +class WriteFreelyApplication(base.OIDCApplication): """ WriteFreely is free, open source, ActivityPub compliant blog software. """ @@ -87,3 +89,33 @@ class GitlabApplication(base.OIDCApplication): obj=service, application_uri=service.config.get("application_uri") ) + + +@register("peertube") +class PeertubeApplication(base.OIDCApplication): + """ PeerTube is free, open source, video publishing software + """ + + name = _("PeerTube") + + class Form(base.BaseForm): + application_uri = fields.StringField(_("PeerTube URL"), [validators.URL(require_tld=False)]) + submit = fields.SubmitField(_('Submit')) + + def populate_service(self, form, service): + service.profile_regex = "[a-z0-9_.\-]*" + callback_uri = form.application_uri.data + "/plugins/auth-openid-connect/router/code-cb" + service.config.update({ + "application_uri": form.application_uri.data, + "token_endpoint_auth_method": "client_secret_basic", + "redirect_uris": [callback_uri], + "grant_types": ["authorization_code"], + "response_types": ["code"], + }) + self.fill_service(service) + + def populate_form(self, service, form): + form.process( + obj=service, + application_uri=service.config.get("application_uri") + ) \ No newline at end of file diff --git a/hiboo/application/templates/application_peertube.html b/hiboo/application/templates/application_peertube.html new file mode 100644 index 00000000..2128c25f --- /dev/null +++ b/hiboo/application/templates/application_peertube.html @@ -0,0 +1,23 @@ +<h3>Setting up PeerTube</h3> +<p>PeerTube supports OIDC authentication using the official <i>auth-openid-connect</i> plugin: https://framagit.org/framasoft/peertube/official-plugins/-/tree/master/peertube-plugin-auth-openid-connect.</p> +<p>Once the plugin is install, to configure OIDC authentication, you should fill the following settings.</p> + +<dt>Discover URL</dt> +<dd><pre>{{ url_for("sso.oidc_discovery", service_uuid=service.uuid, _external=True) }}</pre></dd> + +<dt>Client ID</dt> +<dd><pre>service.config["client_id"]</pre></dd> + +<dt>Client secret</dt> +<dd><pre>service.config["client_secret"]</pre></dd> + +<dt>Scope</dt> +<dd><pre>openid email profile</pre></dd> + +<dt>Username property</dt> +<dd><pre>preferred_username</pre></dd> + +<dt>Email property</dt> +<dd><pre>email</pre></dd> + +{% include "application_oidc.html" %} \ No newline at end of file -- GitLab