diff --git a/hiboo/application/social.py b/hiboo/application/social.py index 2db479b3d8f6aaae2a97469c827811e6ef04f15b..51526966312c9da8db0e4e01b72cdba7137f816d 100644 --- a/hiboo/application/social.py +++ b/hiboo/application/social.py @@ -58,3 +58,32 @@ class SynapseApplication(base.SAMLApplication): obj=service, application_uri=service.config.get("application_uri") ) +@register("writefreely") +class GitlabApplication(base.OIDCApplication): + """ WriteFreely is free, open source, ActivityPub compliant blog software. + """ + + name = _("WriteFreely") + + class Form(base.BaseForm): + application_uri = fields.StringField(_("WriteFreely 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 + "/oauth/callback/generic" + 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"], + "special_mappings": ["ignore_scopes"] + }) + self.fill_service(service) + + def populate_form(self, service, form): + form.process( + obj=service, + application_uri=service.config.get("application_uri") + ) diff --git a/hiboo/application/templates/application_writefreely.html b/hiboo/application/templates/application_writefreely.html new file mode 100644 index 0000000000000000000000000000000000000000..5b46b5970ed7662f3203cf61ff1a43d50bb7caee --- /dev/null +++ b/hiboo/application/templates/application_writefreely.html @@ -0,0 +1,17 @@ +<h3>Setting up WriteFreely</h3> +<p>WriteFreely supports OIDC authentication through Oauth2.</p> +<p>In order to configure Oauth2 for WriteFreely, you may copy then paste the following lines directly into your WriteFreely config.ini and restart.</p> +<pre> +[oauth.generic] +client_id = {{ service.config["client_id"] }} +client_secret = {{ service.config["client_secret"] }} +host = {{ url_for('account.home', _external=True).split('/account')[0] }} +display_name = Hiboo +callback_proxy = +callback_proxy_api = +token_endpoint = {{ url_for("sso.oidc_token", service_uuid=service.uuid, _external=False) }} +inspect_endpoint = {{ url_for("sso.oidc_userinfo", service_uuid=service.uuid, _external=False) }} +auth_endpoint = {{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=False) }} +</pre> + +{% include "application_oidc.html" %} \ No newline at end of file