mirror of
https://github.com/YunoHost-Apps/outline_ynh.git
synced 2024-09-03 19:56:12 +02:00
Create app-03-visitor.patch
This commit is contained in:
parent
afab5522a3
commit
57a02633ad
1 changed files with 69 additions and 0 deletions
69
sources/patches/app-03-visitor.patch
Normal file
69
sources/patches/app-03-visitor.patch
Normal file
|
@ -0,0 +1,69 @@
|
|||
diff --git a/server/routes/auth/providers/req.ts b/server/routes/auth/providers/req.ts
|
||||
index e69de29b..22beba6e 100644
|
||||
--- a/server/routes/auth/providers/req.ts
|
||||
+++ b/server/routes/auth/providers/req.ts
|
||||
@@ -0,0 +1,64 @@
|
||||
+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 { getAllowedDomains } from "@server/utils/authentication";
|
||||
+import { StateStore } from "@server/utils/passport";
|
||||
+
|
||||
+const router = new Router();
|
||||
+const providerName = "req";
|
||||
+const allowedDomains = getAllowedDomains();
|
||||
+
|
||||
+export const config = {
|
||||
+ name: "Visitor",
|
||||
+ 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);
|
||||
+ const name = "Visitor";
|
||||
+ const email = "visitor@domain.tld";
|
||||
+ 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;
|
Loading…
Add table
Reference in a new issue