diff --git a/Dockerfile b/Dockerfile index e87f37f..9b0958d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,12 +12,14 @@ RUN apk add --no-cache \ RUN npm config set unsafe-perm true RUN npm install -g webpack webpack-cli -ENV WIKIJS_VERSION=d78127dc2973d8e773c6ad88e44c253c7fbda1a1 +ENV WIKIJS_VERSION=2.0.12 -RUN git clone https://code.vanwa.ch/sebastian/wikijs.git -b nextcloud-auth /build +RUN git clone https://github.com/Requarks/wiki.git -b $WIKIJS_VERSION /build +ADD nextcloud-auth.patch /build/nextcloud-auth.patch WORKDIR /build -RUN git checkout $WIKIJS_VERSION +#RUN git checkout $WIKIJS_VERSION +RUN git apply nextcloud-auth.patch RUN npm install RUN make build diff --git a/nextcloud-auth.patch b/nextcloud-auth.patch new file mode 100644 index 0000000..2fd27cb --- /dev/null +++ b/nextcloud-auth.patch @@ -0,0 +1,101 @@ +From e26b40f3899efe1dccd1ad218f52b99decce198d Mon Sep 17 00:00:00 2001 +From: Sebastian Hugentobler +Date: Tue, 7 Jan 2020 15:44:06 +0100 +Subject: [PATCH] add nextcloud auth + +--- + package.json | 1 + + .../nextcloud/authentication.js | 36 +++++++++++++++++++ + .../authentication/nextcloud/definition.yml | 25 +++++++++++++ + 3 files changed, 62 insertions(+) + create mode 100644 server/modules/authentication/nextcloud/authentication.js + create mode 100644 server/modules/authentication/nextcloud/definition.yml + +diff --git a/package.json b/package.json +index c4ce2a63..b78ef485 100644 +--- a/package.json ++++ b/package.json +@@ -132,6 +132,7 @@ + "passport-ldapauth": "2.1.3", + "passport-local": "1.0.0", + "passport-microsoft": "0.0.5", ++ "passport-nextcloud": "0.1.1", + "passport-oauth2": "1.5.0", + "passport-okta-oauth": "0.0.1", + "passport-openidconnect": "0.0.2", +diff --git a/server/modules/authentication/nextcloud/authentication.js b/server/modules/authentication/nextcloud/authentication.js +new file mode 100644 +index 00000000..0b58a78d +--- /dev/null ++++ b/server/modules/authentication/nextcloud/authentication.js +@@ -0,0 +1,36 @@ ++/* global WIKI */ ++ ++// ------------------------------------ ++// Nextcloud Account ++// ------------------------------------ ++ ++const NextcloudStrategy = require('passport-nextcloud').Strategy ++const _ = require('lodash') ++ ++module.exports = { ++ init (passport, conf) { ++ passport.use('nextcloud', ++ new NextcloudStrategy({ ++ clientID: conf.clientId, ++ clientSecret: conf.clientSecret, ++ callbackURL: conf.callbackURL, ++ baseURL: conf.baseUrl, ++ scope: ['read_user'] ++ }, async (accessToken, refreshToken, profile, cb) => { ++ try { ++ const user = await WIKI.models.users.processProfile({ ++ profile: { ++ ...profile, ++ // not available from nextcloud so far ++ picture: '' ++ }, ++ providerKey: 'nextcloud' ++ }) ++ cb(null, user) ++ } catch (err) { ++ cb(err, null) ++ } ++ } ++ )) ++ } ++} +diff --git a/server/modules/authentication/nextcloud/definition.yml b/server/modules/authentication/nextcloud/definition.yml +new file mode 100644 +index 00000000..30a136ed +--- /dev/null ++++ b/server/modules/authentication/nextcloud/definition.yml +@@ -0,0 +1,25 @@ ++key: nextcloud ++title: Nextcloud ++description: Nextcloud is a suite of client-server software for creating and using file hosting services. ++author: requarks.io ++logo: https://static.requarks.io/logo/nextcloud.svg ++color: blue darken-1 ++website: https://nextcloud.com ++isAvailable: true ++useForm: false ++props: ++ clientId: ++ type: String ++ title: Client ID ++ hint: Application Client ID ++ order: 1 ++ clientSecret: ++ type: String ++ title: Client Secret ++ hint: Application Client Secret ++ order: 2 ++ baseUrl: ++ type: String ++ title: Base URL ++ hint: Define the base URL (e.g. https://nextcloud.example.com). ++ order: 3 +-- +2.18.1 +