Updates
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
"use strict";(()=>{var e={};e.id=204,e.ids=[204],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},7541:(e,t,r)=>{r.r(t),r.d(t,{config:()=>g,default:()=>h,routeModule:()=>_});var s={};r.r(s),r.d(s,{default:()=>p});var n=r(1802),i=r(7153),u=r(6249),o=r(2632),a=r(2253),d=r(2481),c=r(8804),l=r.n(c),f=r(1282);async function m({user_id:e}){let t=(await l().select({table:"users",targetId:(0,a._n)(e)})).singleRes;if(!t?.id||!t.username||t.is_super_admin)return;let{username:r}=t;console.log("username",r);let{force_command_file:s,sshd_config_file:n}=(0,d.Z)({user:t}),i=`/bin/bash << 'TURBOCIHEREDOC'
|
||||
`;i+=`deluser --remove-all-files ${r} || echo "User Deleted!"
|
||||
rm -f ${s}
|
||||
rm -f ${n}
|
||||
TURBOCIHEREDOC
|
||||
`,(0,f.execSync)(i),l().delete({table:"users",targetId:t.id})}async function p(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{singleRes:r}=await (0,o.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{user_id:s}=e.body;if((0,a._n)(s)==r.id)throw Error("Can't delete root user!");return await m({user_id:(0,a._n)(s)}),t.json({success:!0})}catch(e){return t.json({success:!1,msg:e.message})}}let h=(0,u.l)(s,"default"),g=(0,u.l)(s,"config"),_=new n.PagesAPIRouteModule({definition:{kind:i.x.PAGES_API,page:"/api/admin/delete-user",pathname:"/api/admin/delete-user",bundlePath:"",filename:""},userland:s})},2253:(e,t,r)=>{r.d(t,{dF:()=>u(),_n:()=>c,lV:()=>a()});let s=require("@moduletrace/datasquirel/dist/client");var n=r.n(s);let i=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var u=r.n(i);let o=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var a=r.n(o);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),c=r.n(d)();n().utils.serializeQuery,n().utils.deserializeQuery},6941:(e,t,r)=>{function s(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:s,options:n,value:i}=t[e],u=[`${encodeURIComponent(s)}=${encodeURIComponent(i)}`];n.expires&&u.push(`Expires=${n.expires.toDate().toUTCString()}`),void 0!==n.maxAge&&u.push(`Max-Age=${n.maxAge}`),n.path&&u.push(`Path=${n.path}`),n.domain&&u.push(`Domain=${n.domain}`),n.secure&&u.push("Secure"),n.httpOnly&&u.push("HttpOnly"),r.push(u)}let s=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",s)}function n(e,t){return e.split(";").reduce((e,t)=>{let[r,s]=t.trim().split("=").map(decodeURIComponent);return e[r]=s,e},{})[t]||null}r.d(t,{d8:()=>s,ej:()=>n}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>u});var s=r(2048);let n=require("path");var i=r.n(n);function u(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=i().resolve(__dirname,"../../"),t="/root/.turboci",r=i().join(t,".config"),s=i().join(r,"turboci.json"),n=i().join(t,"deployment_id"),u=i().join(t,".ssh"),o=i().join(u,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:s,TURBOCI_DIR:t,TURBOCI_SSH_DIR:u,TURBOCI_SSH_KEY_FILE:o,TURBOCI_DEPLOYMENT_ID_FILE:n}}();if(!(0,s.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,s.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2481:(e,t,r)=>{r.d(t,{Z:()=>s});function s({user:e}){let{username:t}=e,r=`/home/${t}`,s=`${r}/.ssh`,n=`${s}/${t}`;return{user_dir:r,ssh_dir:s,ssh_key_file:n,sshd_config_file:`/etc/ssh/sshd_config.d/${t}.conf`,force_command_file:`/usr/local/bin/turboci-deployment-user-${t}`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(6941);let n=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var i=r.n(n),u=r(2253),o=r(9786);async function a({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:n}=(0,o.Z)(),a=e?.headers.cookie||t?.headers.get("cookie");if(!a)return{success:!1,msg:"Couldn't grab cookie string"};let d=(0,s.ej)(a,r);if(!d)return{success:!1,msg:`No ${r} found in request object.`};let c=i()({encryptedString:d}),l=u.dF.parse(c);if(!l?.id)return{success:!1,msg:"Invalid Auth Key"};let f=(0,s.ej)(a,n);if(!f)return{success:!1,msg:`No ${n} found in request object.`};if(f!==l.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:l}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=7541);module.exports=r})();
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
"use strict";(()=>{var e={};e.id=482,e.ids=[482],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},4441:(e,t,r)=>{r.r(t),r.d(t,{config:()=>m,default:()=>p,routeModule:()=>f});var i={};r.r(i),r.d(i,{default:()=>c});var s=r(1802),n=r(7153),u=r(6249),a=r(2632),o=r(8804),d=r.n(o),l=r(2048);async function c(e,t){try{let{singleRes:r}=await (0,a.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{user_id:i}=e.query,s=(await d().select({table:"users",targetId:i})).singleRes;if(!s?.username)throw Error("Couldn't grab user");let n=`/home/${s.username}/.ssh/${s.username}`;if(!(0,l.existsSync)(n))throw Error("No Private SSH key file found");(0,l.createReadStream)(n).pipe(t)}catch(e){return t.json({success:!1,msg:e.message})}}let p=(0,u.l)(i,"default"),m=(0,u.l)(i,"config"),f=new s.PagesAPIRouteModule({definition:{kind:n.x.PAGES_API,page:"/api/admin/download-private-ssh-key",pathname:"/api/admin/download-private-ssh-key",bundlePath:"",filename:""},userland:i})},2253:(e,t,r)=>{r.d(t,{dF:()=>u(),_n:()=>l,lV:()=>o()});let i=require("@moduletrace/datasquirel/dist/client");var s=r.n(i);let n=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var u=r.n(n);let a=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var o=r.n(a);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),l=r.n(d)();s().utils.serializeQuery,s().utils.deserializeQuery},6941:(e,t,r)=>{function i(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:i,options:s,value:n}=t[e],u=[`${encodeURIComponent(i)}=${encodeURIComponent(n)}`];s.expires&&u.push(`Expires=${s.expires.toDate().toUTCString()}`),void 0!==s.maxAge&&u.push(`Max-Age=${s.maxAge}`),s.path&&u.push(`Path=${s.path}`),s.domain&&u.push(`Domain=${s.domain}`),s.secure&&u.push("Secure"),s.httpOnly&&u.push("HttpOnly"),r.push(u)}let i=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",i)}function s(e,t){return e.split(";").reduce((e,t)=>{let[r,i]=t.trim().split("=").map(decodeURIComponent);return e[r]=i,e},{})[t]||null}r.d(t,{d8:()=>i,ej:()=>s}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>u});var i=r(2048);let s=require("path");var n=r.n(s);function u(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=n().resolve(__dirname,"../../"),t="/root/.turboci",r=n().join(t,".config"),i=n().join(r,"turboci.json"),s=n().join(t,"deployment_id"),u=n().join(t,".ssh"),a=n().join(u,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:i,TURBOCI_DIR:t,TURBOCI_SSH_DIR:u,TURBOCI_SSH_KEY_FILE:a,TURBOCI_DEPLOYMENT_ID_FILE:s}}();if(!(0,i.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,i.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(6941);let s=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var n=r.n(s),u=r(2253),a=r(9786);async function o({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:s}=(0,a.Z)(),o=e?.headers.cookie||t?.headers.get("cookie");if(!o)return{success:!1,msg:"Couldn't grab cookie string"};let d=(0,i.ej)(o,r);if(!d)return{success:!1,msg:`No ${r} found in request object.`};let l=n()({encryptedString:d}),c=u.dF.parse(l);if(!c?.id)return{success:!1,msg:"Invalid Auth Key"};let p=(0,i.ej)(o,s);if(!p)return{success:!1,msg:`No ${s} found in request object.`};if(p!==c.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:c}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=4441);module.exports=r})();
|
||||
File diff suppressed because one or more lines are too long
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";(()=>{var e={};e.id=837,e.ids=[837],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},8635:(e,t,r)=>{r.r(t),r.d(t,{config:()=>p,default:()=>h,routeModule:()=>f});var s={};r.r(s),r.d(s,{default:()=>m});var n=r(1802),i=r(7153),o=r(6249),u=r(2632),a=r(8804),c=r.n(a),d=r(2253),l=r(246);async function m(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{singleRes:r}=await (0,u.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{new_user:s,user_id:n}=e.body;if(!s)throw Error("No User Form Sent.");let{first_name:i,last_name:o,email:a,image:m,username:h}=s;if(!i?.match(/./))return t.json({success:!1,msg:"First name is required"});return await c().update({table:"users",targetId:(0,d._n)(n),data:{first_name:i,last_name:o,email:a,image:m,username:h}}),await (0,l.Z)({user_id:(0,d._n)(n)}),t.json({success:!0})}catch(e){return t.json({success:!1,msg:e.message})}}let h=(0,o.l)(s,"default"),p=(0,o.l)(s,"config"),f=new n.PagesAPIRouteModule({definition:{kind:i.x.PAGES_API,page:"/api/admin/edit-user",pathname:"/api/admin/edit-user",bundlePath:"",filename:""},userland:s})},2253:(e,t,r)=>{r.d(t,{dF:()=>o(),_n:()=>d,lV:()=>a()});let s=require("@moduletrace/datasquirel/dist/client");var n=r.n(s);let i=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var o=r.n(i);let u=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var a=r.n(u);let c=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),d=r.n(c)();n().utils.serializeQuery,n().utils.deserializeQuery},246:(e,t,r)=>{r.d(t,{Z:()=>c});var s=r(2253),n=r(2481),i=r(8804),o=r.n(i),u=r(1282),a=r(2048);async function c({user_id:e}){let t=(await o().select({table:"users",targetId:(0,s._n)(e)})).singleRes;if(!t?.id||!t.username||t.is_super_admin)return;let{username:r}=t,{force_command_file:i,ssh_dir:c,ssh_key_file:d,sshd_config_file:l,user_dir:m}=(0,n.Z)({user:t}),h=`/bin/bash << 'TURBOCIHEREDOC'
|
||||
`;(0,a.existsSync)(m)||(h+=`useradd --create-home --shell /bin/bash --comment "TurboCI Deployment user ${r}" ${r}
|
||||
passwd --lock "${r}"
|
||||
mkdir -p "${c}"
|
||||
ssh-keygen -t ed25519 -f "${d}" -N "" -C "${r}@$(hostname)"
|
||||
cp "${d}.pub" "${c}/authorized_keys"
|
||||
chown -R "${r}:${r}" "${c}"
|
||||
chmod 700 "${c}"
|
||||
chmod 600 "${d}"
|
||||
chmod 644 "${d}.pub"
|
||||
chmod 600 "${c}/authorized_keys"
|
||||
`),h+=`cat << 'EOF' > ${i}
|
||||
#!/bin/bash
|
||||
case "$SSH_ORIGINAL_COMMAND" in
|
||||
"shell")
|
||||
exec /bin/bash
|
||||
;;
|
||||
*)
|
||||
echo "Access denied."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
|
||||
chmod +x ${i}
|
||||
|
||||
cat << 'EOF' > ${l}
|
||||
Match User ${r}
|
||||
PasswordAuthentication no
|
||||
PubkeyAuthentication yes
|
||||
AuthenticationMethods publickey
|
||||
AllowTcpForwarding yes
|
||||
X11Forwarding no
|
||||
ForceCommand ${i}
|
||||
PermitOpen localhost:80
|
||||
PermitTTY no
|
||||
EOF
|
||||
TURBOCIHEREDOC
|
||||
`,(0,u.execSync)(h)}},6941:(e,t,r)=>{function s(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:s,options:n,value:i}=t[e],o=[`${encodeURIComponent(s)}=${encodeURIComponent(i)}`];n.expires&&o.push(`Expires=${n.expires.toDate().toUTCString()}`),void 0!==n.maxAge&&o.push(`Max-Age=${n.maxAge}`),n.path&&o.push(`Path=${n.path}`),n.domain&&o.push(`Domain=${n.domain}`),n.secure&&o.push("Secure"),n.httpOnly&&o.push("HttpOnly"),r.push(o)}let s=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",s)}function n(e,t){return e.split(";").reduce((e,t)=>{let[r,s]=t.trim().split("=").map(decodeURIComponent);return e[r]=s,e},{})[t]||null}r.d(t,{d8:()=>s,ej:()=>n}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>o});var s=r(2048);let n=require("path");var i=r.n(n);function o(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=i().resolve(__dirname,"../../"),t="/root/.turboci",r=i().join(t,".config"),s=i().join(r,"turboci.json"),n=i().join(t,"deployment_id"),o=i().join(t,".ssh"),u=i().join(o,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:s,TURBOCI_DIR:t,TURBOCI_SSH_DIR:o,TURBOCI_SSH_KEY_FILE:u,TURBOCI_DEPLOYMENT_ID_FILE:n}}();if(!(0,s.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,s.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2481:(e,t,r)=>{r.d(t,{Z:()=>s});function s({user:e}){let{username:t}=e,r=`/home/${t}`,s=`${r}/.ssh`,n=`${s}/${t}`;return{user_dir:r,ssh_dir:s,ssh_key_file:n,sshd_config_file:`/etc/ssh/sshd_config.d/${t}.conf`,force_command_file:`/usr/local/bin/turboci-deployment-user-${t}`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(6941);let n=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var i=r.n(n),o=r(2253),u=r(9786);async function a({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:n}=(0,u.Z)(),a=e?.headers.cookie||t?.headers.get("cookie");if(!a)return{success:!1,msg:"Couldn't grab cookie string"};let c=(0,s.ej)(a,r);if(!c)return{success:!1,msg:`No ${r} found in request object.`};let d=i()({encryptedString:c}),l=o.dF.parse(d);if(!l?.id)return{success:!1,msg:"Invalid Auth Key"};let m=(0,s.ej)(a,n);if(!m)return{success:!1,msg:`No ${n} found in request object.`};if(m!==l.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:l}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=8635);module.exports=r})();
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user