diff --git a/hiboo/application/storage.py b/hiboo/application/storage.py index 1d5c45fb8c061dccfd65dac2c7430d217da62e95..12e025fcc08e53f0e8dae98823666ea68925e810 100644 --- a/hiboo/application/storage.py +++ b/hiboo/application/storage.py @@ -32,3 +32,34 @@ class GitlabApplication(base.OIDCApplication): obj=service, application_uri=service.config.get("application_uri") ) + + +@register("seafile") +class SeafileApplication(base.OIDCApplication): + """ Seafile is a file sharing and synchronization application with a Web viewer + """ + + name = _("Seafile") + + class Form(base.BaseForm): + application_uri = fields.StringField(_("Seafile 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 + "/users/auth/openid_connect/callback" + service.config.update({ + "application_uri": form.application_uri.data, + "token_endpoint_auth_method": "client_secret_post", + "redirect_uris": [callback_uri], + "grant_types": ["authorization_code"], + "response_types": ["code"], + "special_mappings": [] + }) + 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_seafile.html b/hiboo/application/templates/application_seafile.html new file mode 100644 index 0000000000000000000000000000000000000000..5cd58655149bee2f88f191b83ebd4dee0b8160c1 --- /dev/null +++ b/hiboo/application/templates/application_seafile.html @@ -0,0 +1,23 @@ +<h3>Setting up Seafile</h3> +<p>Seafile supports OIDC authentication through its Seahub frontend.</p> +<p>In order to enable OIDC, you may add the following settings to your `seahub_settings.py` file.</p> +<pre> +# Authentication +ENABLE_OAUTH = True +OAUTH_ENABLE_INSECURE_TRANSPORT = True +OAUTH_CLIENT_ID = "{{ service.config["client_id"] }}" +OAUTH_CLIENT_SECRET = "{{ service.config["client_secret"] }}" +OAUTH_REDIRECT_URL = "{{ service.config["redirect_uris"][0] }}" +OAUTH_PROVIDER_DOMAIN = "<your hiboo domain>" +OAUTH_AUTHORIZATION_URL = "{{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=True) }}" +OAUTH_TOKEN_URL = "{{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=True) }}" +OAUTH_USER_INFO_URL = "{{ url_for("sso.oidc_authorize", service_uuid=service.uuid, _external=True) }}" +OAUTH_SCOPE = ["openid", "profile", "email"] +OAUTH_ATTRIBUTE_MAP = { + "id": (False, "no_destination"), + "name": (True, "name"), + "email": (True, "email") +} +</pre> + +{% include "application_oidc.html" %} \ No newline at end of file