fix: permission issues

fix: white labaled version
This commit is contained in:
Andras Bacsai 2022-07-08 13:38:19 +02:00
parent c63237684a
commit 222adb212b
10 changed files with 85 additions and 46 deletions

View File

@ -8,4 +8,5 @@ package
!.env.example
dist
client
apps/api/db/*.db
apps/api/db/*.db
local-serve

3
.gitignore vendored
View File

@ -8,4 +8,5 @@ package
!.env.example
dist
client
apps/api/db/*.db
apps/api/db/*.db
local-serve

View File

@ -68,7 +68,8 @@ const schema = {
};
const options = {
schema
schema,
dotenv: true
};
fastify.register(env, options);
if (!isDev) {
@ -76,7 +77,7 @@ if (!isDev) {
root: path.join(__dirname, './public'),
preCompressed: true
});
fastify.setNotFoundHandler(function (request, reply) {
fastify.setNotFoundHandler({}, function (request, reply) {
if (request.raw.url && request.raw.url.startsWith('/api')) {
return reply.status(404).send({
success: false

View File

@ -15,6 +15,9 @@ import { checkContainer, getEngine, removeContainer } from './docker';
import { day } from './dayjs';
import * as serviceFields from './serviceFields'
export const version = '3.0.4';
export const isDev = process.env.NODE_ENV === 'development';
const algorithm = 'aes-256-ctr';
const customConfig: Config = {
dictionaries: [adjectives, colors, animals],
@ -22,8 +25,6 @@ const customConfig: Config = {
separator: ' ',
length: 3
};
export const isDev = process.env.NODE_ENV === 'development';
export const version = '3.0.3';
export const defaultProxyImage = `coolify-haproxy-alpine:latest`;
export const defaultProxyImageTcp = `coolify-haproxy-tcp-alpine:latest`;

View File

@ -0,0 +1,19 @@
import { FastifyPluginAsync } from 'fastify';
import { errorHandler, version } from '../../../../lib/common';
const root: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
fastify.get('/', async (request) => {
try {
return {
version,
whiteLabeled: process.env.COOLIFY_WHITE_LABELED === 'true',
whiteLabeledIcon: process.env.COOLIFY_WHITE_LABELED_ICON,
}
} catch ({ status, message }) {
return errorHandler({ status, message })
}
});
};
export default root;

View File

@ -258,11 +258,12 @@ export async function getCurrentUser(request: FastifyRequest, fastify) {
include: { teams: true, permission: true }
})
if (user) {
const permission = user.permission.find(p => p.teamId === request.query.teamId).permission
const payload = {
...request.user,
teamId: request.query.teamId,
permission: user.permission.find(p => p.teamId === request.query.teamId).permission || null,
isAdmin: user.permission.find(p => p.teamId === request.query.teamId).permission === 'owner'
permission: permission || null,
isAdmin: permission === 'owner' || permission === 'admin'
}
token = fastify.jwt.sign(payload)

View File

@ -1,8 +1,7 @@
import { browser } from '$app/env';
import { writable, readable, type Writable, type Readable } from 'svelte/store';
// import { version as currentVersion } from '../../package.json';
interface AppSession {
version: string
version: string | null,
userId: string | null,
teamId: string | null,
permission: string,
@ -18,7 +17,7 @@ interface AppSession {
}
export const loginEmail: Writable<string | undefined> = writable()
export const appSession: Writable<AppSession> = writable({
version: '3.0.3',
version: null,
userId: null,
teamId: null,
permission: 'read',

View File

@ -1,12 +1,14 @@
<script context="module" lang="ts">
import type { Load } from '@sveltejs/kit';
export const load: Load = async ({ url }) => {
const baseSettings = await get('/base');
try {
if (Cookies.get('token')) {
const response = await get(`/user`);
return {
props: {
...response
...response,
baseSettings
},
stuff: {
...response
@ -16,10 +18,17 @@
if (url.pathname !== '/login' && url.pathname !== '/register') {
return {
status: 302,
redirect: '/login'
redirect: '/login',
props: {
baseSettings
}
};
}
return {};
return {
props: {
baseSettings
}
};
}
} catch (error: any) {
if (error?.code?.startsWith('FAST_JWT') || error.status === 401) {
@ -27,25 +36,39 @@
if (url.pathname !== '/login') {
return {
status: 302,
redirect: '/login'
redirect: '/login',
props: {
baseSettings
}
};
}
}
if (url.pathname !== '/login') {
return {
status: 302,
redirect: '/login'
redirect: '/login',
props: {
baseSettings
}
};
}
return {
status: 500,
error: new Error(error)
error: new Error(error),
props: {
baseSettings
}
};
}
};
</script>
<script lang="ts">
export let baseSettings: any;
$appSession.version = baseSettings.version;
$appSession.whiteLabeled = baseSettings.whiteLabeled;
$appSession.whiteLabeledDetails.icon = baseSettings.whiteLabeledIcon;
export let settings: any;
export let userId: string;
export let teamId: string;
@ -54,7 +77,6 @@
import '../tailwind.css';
import Cookies from 'js-cookie';
import { fade } from 'svelte/transition';
import { SvelteToast } from '@zerodevx/svelte-toast';
import { navigating, page } from '$app/stores';

View File

@ -1,7 +1,7 @@
{
"name": "coolify",
"version": "3.0.3",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.0.4",
"license": "AGPL-3.0",
"scripts": {
"db:studio": "pnpm run --filter coolify-api db:studio",
@ -17,7 +17,8 @@
"build": "NODE_ENV=production run-p -n build:*",
"build:api": "NODE_ENV=production pnpm run --filter coolify-api build",
"build:ui": "NODE_ENV=production pnpm run --filter coolify-ui build",
"release:staging:amd": "cross-var docker buildx build --platform linux/amd64 -t coollabsio/coolify:$npm_package_version --push ."
"release:staging:amd": "cross-var docker buildx build --platform linux/amd64 -t coollabsio/coolify:$npm_package_version --push .",
"release:local":"rm -fr ./local-serve && mkdir ./local-serve && pnpm build && cp -Rp apps/api/build/* ./local-serve && cp -Rp apps/ui/build/ ./local-serve/public && cp -Rp apps/api/prisma/ ./local-serve/prisma && cp -Rp apps/api/package.json ./local-serve && cp .env ./local-serve && cd ./local-serve && pnpm install . && pnpm start"
},
"devDependencies": {
"cross-var": "1.1.0",

View File

@ -1837,7 +1837,7 @@ packages:
clf-date: 0.2.0
iserror: 0.0.2
ms: 2.1.3
on-finished: 2.3.0
on-finished: 2.4.1
parse-err: 0.0.12
parse-request: 4.0.0
transitivePeerDependencies:
@ -2004,7 +2004,7 @@ packages:
dev: false
/concat-map/0.0.1:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
/console-control-strings/1.1.0:
@ -2206,7 +2206,7 @@ packages:
dev: true
/delayed-stream/1.0.0:
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
engines: {node: '>=0.4.0'}
dev: false
@ -2252,7 +2252,7 @@ packages:
dev: true
/dezalgo/1.0.3:
resolution: {integrity: sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=}
resolution: {integrity: sha512-K7i4zNfT2kgQz3GylDw40ot9GAE47sFZ9EXHFSPP6zONLgH6kWXE0KWJchkbQJLBkRazq4APwZ4OwiFFlT95OQ==}
dependencies:
asap: 2.0.6
wrappy: 1.0.2
@ -2346,7 +2346,7 @@ packages:
dev: false
/ee-first/1.1.1:
resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=}
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
dev: false
/electron-to-chromium/1.4.139:
@ -3059,7 +3059,7 @@ packages:
dev: true
/fs.realpath/1.0.0:
resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=}
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
/fsevents/2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
@ -3371,7 +3371,7 @@ packages:
dev: true
/inflight/1.0.6:
resolution: {integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=}
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
dependencies:
once: 1.4.0
wrappy: 1.0.2
@ -3413,7 +3413,7 @@ packages:
dev: false
/is-arrayish/0.2.1:
resolution: {integrity: sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=}
resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==}
/is-bigint/1.0.4:
resolution: {integrity: sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==}
@ -3568,7 +3568,7 @@ packages:
dev: true
/is-uuid/1.0.2:
resolution: {integrity: sha1-rRiY3fFUlHwlyOVJZvSGBOnK7MQ=}
resolution: {integrity: sha512-tCByphFcJgf2qmiMo5hMCgNAquNSagOetVetDvBXswGkNfoyEMvGH1yDlF8cbZbKnbVBr4Y5/rlpMz9umxyBkQ==}
dev: false
/is-valid-path/0.1.1:
@ -3585,11 +3585,11 @@ packages:
dev: true
/iserror/0.0.2:
resolution: {integrity: sha1-vVNFH+L2aLnyQCwZZnh6qix8C/U=}
resolution: {integrity: sha512-oKGGrFVaWwETimP3SiWwjDeY27ovZoyZPHtxblC4hCq9fXxed/jasx+ATWFFjCVSRZng8VTMsN1nDnGo6zMBSw==}
dev: false
/isexe/2.0.0:
resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=}
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
/js-cookie/3.0.1:
resolution: {integrity: sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw==}
@ -3817,7 +3817,7 @@ packages:
dev: true
/lodash.omit/4.5.0:
resolution: {integrity: sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=}
resolution: {integrity: sha512-XeqSp49hNGmlkj2EJlfrQFIzQ6lXdNro9sddtQzcJY8QaoC2GO0DT7xaIokHeyM+mIT0mPMlPvkYzg2xCuHdZg==}
dev: false
/lodash.once/4.1.1:
@ -3842,7 +3842,7 @@ packages:
dev: true
/lower-case/1.1.4:
resolution: {integrity: sha1-miyr0bno4K6ZOkv31YdcOcQujqw=}
resolution: {integrity: sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==}
dev: false
/lowercase-keys/2.0.0:
@ -3903,7 +3903,7 @@ packages:
dev: true
/methods/1.1.2:
resolution: {integrity: sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=}
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
engines: {node: '>= 0.6'}
dev: false
@ -4051,7 +4051,7 @@ packages:
dev: true
/next-line/1.1.0:
resolution: {integrity: sha1-/K5XhTBStqm66CCOQN19PC0wRgM=}
resolution: {integrity: sha512-+I10J3wKNoKddNxn0CNpoZ3eTZuqxjNM3b1GImVx22+ePI+Y15P8g/j3WsbP0fhzzrFzrtjOAoq5NCCucswXOQ==}
dev: false
/nice-try/1.0.5:
@ -4219,13 +4219,6 @@ packages:
resolution: {integrity: sha512-VuCaZZAjReZ3vUwgOB8LxAosIurDiAW0s13rI1YwmaP++jvcxP77AWoQvenZebpCA2m8WC1/EosPYPMjnRAp/w==}
dev: false
/on-finished/2.3.0:
resolution: {integrity: sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=}
engines: {node: '>= 0.8'}
dependencies:
ee-first: 1.1.1
dev: false
/on-finished/2.4.1:
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
engines: {node: '>= 0.8'}
@ -4234,7 +4227,7 @@ packages:
dev: false
/once/1.4.0:
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
dependencies:
wrappy: 1.0.2
@ -4824,7 +4817,7 @@ packages:
dev: false
/requires-port/1.0.0:
resolution: {integrity: sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=}
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
dev: false
/resolve-alpn/1.2.1:
@ -5726,7 +5719,7 @@ packages:
dev: true
/wrappy/1.0.2:
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
/xtend/4.0.2:
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}