From 27fd10f2a6c76fbf751cb76a8973be68971c4088 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 29 Oct 2017 23:52:09 -0700 Subject: [PATCH 1/6] Prefix s3 user uploads with `uploads/` --- server/api/user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/api/user.js b/server/api/user.js index a68dcedcf..15e4ed6bd 100644 --- a/server/api/user.js +++ b/server/api/user.js @@ -18,7 +18,7 @@ router.post('user.s3Upload', auth(), async ctx => { ctx.assertPresent(size, 'size is required'); const s3Key = uuid.v4(); - const key = `${s3Key}/${filename}`; + const key = `uploads/${s3Key}/${filename}`; const policy = makePolicy(); ctx.body = { @@ -36,7 +36,7 @@ router.post('user.s3Upload', auth(), async ctx => { }, asset: { contentType: kind, - url: `${process.env.AWS_S3_UPLOAD_BUCKET_URL}${s3Key}/${filename}`, + url: `${process.env.AWS_S3_UPLOAD_BUCKET_URL}${key}`, name: filename, size, }, From 8b4f8f46a4ba5a9f186b94cd5b513b7f39bc077c Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 30 Oct 2017 00:13:05 -0700 Subject: [PATCH 2/6] Update README.md --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84757702f..a17524fb6 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,24 @@ ![](https://circleci.com/gh/jorilallo/atlas.svg?style=shield&circle-token=c0c4c2f39990e277385d5c1ae96169c409eb887a) +Atlas is a modern wiki for your team build using React and Node.js. + ## Installation +Atlas requires following dependencies to work: + +- Postgres >=9.5 +- Redis +- S3 bucket configured to support CORS uploads +- Slack developer application + +To install and run the application: + 1. Install dependencies with `yarn` 1. Register a Slack app at https://api.slack.com/apps 1. Copy the file `.env.sample` to `.env` and fill out the keys - 1. Run DB migrations `yarn sequelize -- db:migrate` + - Use `openssl rand -hex 32` to create `SEQUELIZE_SECRET` + 1. Run DB migrations `yarn sequelize db:migrate` 1. Start the development server `yarn start` @@ -25,3 +37,8 @@ Or to run migrations on test database: ``` yarn sequelize db:migrate --env test ``` + + +## License + +Atlas is [BSD licensed](/blob/master/LICENSE). From bcd10584a89087a26eec8e5f4d6acfc0f5c28c44 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 30 Oct 2017 00:23:22 -0700 Subject: [PATCH 3/6] Updates to README --- LICENSE | 19 +++++++++++++++++++ README.md | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..170d8cdf8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2017 Atlas (https://www.beautifulatlas.com/) and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Sentry nor the names of its contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index a17524fb6..01c90bb23 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![](https://circleci.com/gh/jorilallo/atlas.svg?style=shield&circle-token=c0c4c2f39990e277385d5c1ae96169c409eb887a) -Atlas is a modern wiki for your team build using React and Node.js. +Atlas is a modern wiki for your team build using React and Node.js. [https://www.beautifulatlas.com/](https://www.beautifulatlas.com/) ## Installation From 317214ce13f93f3d6888498e2f91d54f92e2c398 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 30 Oct 2017 00:26:45 -0700 Subject: [PATCH 4/6] SEQUELIZE_SECRET changes --- .env.sample | 2 ++ README.md | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index d0698531a..66b83dc1b 100644 --- a/.env.sample +++ b/.env.sample @@ -1,4 +1,6 @@ # Copy this file to .env, remove this comment and change the keys +# +# Please use `openssl rand -hex 32` to create SEQUELIZE_SECRET DATABASE_URL=postgres://user:pass@example.com:5432/atlas DATABASE_URL_TEST=postgres://user:pass@example.com:5432/atlas-test diff --git a/README.md b/README.md index 01c90bb23..f8d1f51b0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ To install and run the application: 1. Install dependencies with `yarn` 1. Register a Slack app at https://api.slack.com/apps 1. Copy the file `.env.sample` to `.env` and fill out the keys - - Use `openssl rand -hex 32` to create `SEQUELIZE_SECRET` 1. Run DB migrations `yarn sequelize db:migrate` 1. Start the development server `yarn start` From b97497460ba50db4d59e2314ad34027edbb1d78c Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 30 Oct 2017 22:24:51 -0700 Subject: [PATCH 5/6] nits --- LICENSE | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 170d8cdf8..b5cec1326 100644 --- a/LICENSE +++ b/LICENSE @@ -8,7 +8,7 @@ Redistribution and use in source and binary forms, with or without modification, 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name of the Sentry nor the names of its contributors may be used to endorse or promote products derived from this software + 3. Neither the name of the Atlas nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, diff --git a/README.md b/README.md index f8d1f51b0..89b7d70ac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![](https://circleci.com/gh/jorilallo/atlas.svg?style=shield&circle-token=c0c4c2f39990e277385d5c1ae96169c409eb887a) -Atlas is a modern wiki for your team build using React and Node.js. [https://www.beautifulatlas.com/](https://www.beautifulatlas.com/) +Atlas is a modern wiki for your team built using React and Node.js. [https://www.beautifulatlas.com/](https://www.beautifulatlas.com/) ## Installation From c9fc8801378e2d5ff55b157662236626080ff37b Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 30 Oct 2017 22:35:30 -0700 Subject: [PATCH 6/6] include user id in the uploads path --- server/api/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/api/user.js b/server/api/user.js index 15e4ed6bd..64b3676fb 100644 --- a/server/api/user.js +++ b/server/api/user.js @@ -18,7 +18,7 @@ router.post('user.s3Upload', auth(), async ctx => { ctx.assertPresent(size, 'size is required'); const s3Key = uuid.v4(); - const key = `uploads/${s3Key}/${filename}`; + const key = `uploads/${ctx.state.user.id}/${s3Key}/${filename}`; const policy = makePolicy(); ctx.body = {