1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/outline_ynh.git synced 2024-09-03 19:56:12 +02:00
outline_ynh/sources/patches/app-03-visitor.patch

126 lines
4 KiB
Diff
Raw Normal View History

2022-09-10 18:17:17 +02:00
diff --git a/server/routes/auth/providers/req.ts b/server/routes/auth/providers/req.ts
new file mode 100644
2022-11-12 17:21:10 +01:00
index 000000000..be344d2e2
2022-09-10 18:17:17 +02:00
--- /dev/null
+++ b/server/routes/auth/providers/req.ts
2022-09-10 19:35:52 +02:00
@@ -0,0 +1,62 @@
2022-09-10 18:17:17 +02:00
+import passport from "@outlinewiki/koa-passport";
+import Router from "koa-router";
+import { capitalize } from "lodash";
+import { Strategy as ReqStrategy } from "passport-req";
+import accountProvisioner from "@server/commands/accountProvisioner";
+import env from "@server/env";
+import passportMiddleware from "@server/middlewares/passport";
+import { StateStore } from "@server/utils/passport";
+
+const router = new Router();
+const providerName = "req";
+
+export const config = {
2022-09-16 17:59:46 +02:00
+ name: "visiteur",
2022-09-10 18:17:17 +02:00
+ enabled: true,
+};
+
+if (true) {
+ passport.use(
+ new ReqStrategy(
+ async function (req,done) {
+ try {
+ const domain = "domain.tld";
+ const subdomain = domain.split(".")[0];
+ const teamName = capitalize(subdomain);
2022-09-16 20:00:33 +02:00
+ const name = "visiteur";
+ const email = "visiteur@anthropologiebiblique.fr";
2022-09-10 18:17:17 +02:00
+ const result = await accountProvisioner({
+ ip: req.ip,
+ team: {
+ name: teamName,
+ domain,
+ subdomain,
+ },
+ user: {
+ name: name,
+ email: email,
+ avatarUrl: null,
+ },
+ authenticationProvider: {
+ name: providerName,
+ providerId: domain,
+ },
+ authentication: {
+ providerId: "1234",
+ accessToken: null,
+ refreshToken: null,
+ scopes: [],
+ },
+ });
+ return done(null, result.user, result);
+ } catch (err) {
+ return done(err, null);
+ }
+ }
+ )
+ );
+
+ router.get("req", passportMiddleware(providerName));
+}
+
+export default router;
diff --git a/yarn.lock b/yarn.lock
2023-02-16 17:44:51 +01:00
index 352d1993a..5e3c24636 100644
2022-09-10 18:17:17 +02:00
--- a/yarn.lock
+++ b/yarn.lock
2023-02-16 17:44:51 +01:00
@@ -10760,6 +10760,14 @@ passport-oauth@1.0.x:
2022-09-10 18:17:17 +02:00
passport-oauth1 "1.x.x"
passport-oauth2 "1.x.x"
+passport-req@^0.1.1:
+ version "0.1.1"
2022-09-10 19:03:42 +02:00
+ resolved "https://registry.yarnpkg.com/passport-req/-/passport-req-0.1.1.tgz#451bff1500b3d464a768d42f0762328a21236a18"
2022-11-12 17:21:10 +01:00
+ integrity sha512-9qmM0vD5v7jYLWxezNNCleOw+8IkVAuvOwQ6NJaUuJkdFJTR1KatXH1i5MxWgffx+libLWYLRUPtc6GHOmn+6w==
2022-09-10 18:17:17 +02:00
+ dependencies:
+ passport "~0.1.1"
+ pkginfo "0.2.x"
+
passport-slack-oauth2@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/passport-slack-oauth2/-/passport-slack-oauth2-1.1.1.tgz#d831ffc3f1e968fcc3622e6ecf41643c8d8f9cbc"
2023-02-16 17:44:51 +01:00
@@ -10782,6 +10790,14 @@ passport@^0.6.0:
2022-11-12 17:21:10 +01:00
pause "0.0.1"
utils-merge "^1.0.1"
+passport@~0.1.1:
+ version "0.1.18"
+ resolved "https://registry.yarnpkg.com/passport/-/passport-0.1.18.tgz#c8264479dcb6414cadbb66752d12b37e0b6525a1"
+ integrity sha512-qteYojKG/qth7UBbbGU7aqhe5ndJs6YaUkH2B6+7FWQ0OeyYmWknzOATpMhdoSTDcLLliq9n4Fcy1mGs80iUMw==
+ dependencies:
+ pause "0.0.1"
+ pkginfo "0.2.x"
+
passthrough-counter@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/passthrough-counter/-/passthrough-counter-1.0.0.tgz#1967d9e66da572b5c023c787db112a387ab166fa"
2023-02-16 17:44:51 +01:00
@@ -11005,6 +11021,11 @@ pkg-up@^3.1.0:
2022-11-12 17:21:10 +01:00
dependencies:
find-up "^3.0.0"
+pkginfo@0.2.x:
+ version "0.2.3"
+ resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.2.3.tgz#7239c42a5ef6c30b8f328439d9b9ff71042490f8"
+ integrity sha512-7W7wTrE/NsY8xv/DTGjwNIyNah81EQH0MWcTzrHL6pOpMocOGZc0Mbdz9aXxSrp+U0mSmkU8jrNCDCfUs3sOBg==
+
pkginfo@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
2022-11-12 18:07:44 +01:00
diff --git a/package.json b/package.json
2023-02-17 09:24:25 +01:00
index 787991dc1..7d610c010 100644
2022-11-12 18:07:44 +01:00
--- a/package.json
+++ b/package.json
2023-02-16 17:44:51 +01:00
@@ -150,6 +150,7 @@
2022-11-12 18:07:44 +01:00
"passport": "^0.6.0",
"passport-google-oauth2": "^0.2.0",
"passport-oauth2": "^1.6.1",
+ "passport-req": "^0.1.1",
"passport-slack-oauth2": "^1.1.1",
"pg": "^8.8.0",
2023-02-17 03:44:46 +01:00
"pg-hstore": "^2.3.4",