refactor(docs): move media guides
The media guides should also live in their own folder like the auth guides do as well Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
committed by
Erik Michelson
parent
814271dc0b
commit
f1070734b1
94
docs/content/guides/media/minio-image-upload.md
Normal file
94
docs/content/guides/media/minio-image-upload.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# Minio Guide for HedgeDoc
|
||||
|
||||
**Note:** *This guide was written before the renaming. Just replace `HackMD` with `HedgeDoc` in your mind 😃 thanks!*
|
||||
|
||||
1. First of all you need to setup Minio itself.
|
||||
|
||||
Please refer to the [official Minio docs](https://docs.minio.io/) for an
|
||||
production setup.
|
||||
|
||||
For checking it out and development purposes a non-persistent setup is enough:
|
||||
```sh
|
||||
docker run --name test-minio --rm -d -p 9000:9000 minio/minio server /data
|
||||
```
|
||||
|
||||
*Please notice this is not for productive use as all your data gets lost
|
||||
when you stop this container*
|
||||
|
||||
2. Next step is to get the credentials form the container:
|
||||
|
||||
```sh
|
||||
docker logs test-minio
|
||||
```
|
||||
|
||||

|
||||
|
||||
3. Open <http://localhost:9000> and login with the shown credentials.
|
||||
|
||||

|
||||
|
||||
4. Create a bucket for HedgeDoc
|
||||
|
||||

|
||||
|
||||
5. Add a policy for the prefix `uploads` and make it read-only.
|
||||
|
||||

|
||||
*Open policy editor*
|
||||
|
||||

|
||||
*Add policy for uploads*
|
||||
|
||||
6. Set credentials and configs for Minio in HedgeDoc's `config.json`
|
||||
|
||||
```JSON
|
||||
"minio": {
|
||||
"accessKey": "888MXJ7EP4XXXXXXXXX",
|
||||
"secretKey": "yQS2EbM1Y6IJrp/1BUKWq2/XXXXXXXXXXXXXXX",
|
||||
"endPoint": "localhost",
|
||||
"port": 9000,
|
||||
"secure": false
|
||||
}
|
||||
```
|
||||
*You have to use different values for `endpoint` and `port` for a production
|
||||
setup. Keep in mind the `endpoint`-address has to be public accessible from
|
||||
your browser.*
|
||||
|
||||
7. Set bucket name
|
||||
|
||||
```JSON
|
||||
"s3bucket": "hedgedoc"
|
||||
```
|
||||
|
||||
8. Set upload type.
|
||||
|
||||
```JSON
|
||||
"imageuploadtype": "minio"
|
||||
```
|
||||
|
||||
9. Review your config.
|
||||
|
||||
```json
|
||||
{
|
||||
// all your other config…
|
||||
"minio": {
|
||||
"accessKey": "888MXJ7EP4XXXXXXXXX",
|
||||
"secretKey": "yQS2EbM1Y6IJrp/1BUKWq2/XXXXXXXXXXXXXXX",
|
||||
"endPoint": "localhost",
|
||||
"port": 9000,
|
||||
"secure": false
|
||||
},
|
||||
"s3bucket": "hedgedoc",
|
||||
"imageuploadtype": "minio"
|
||||
}
|
||||
```
|
||||
|
||||
10. If you were using filesystem before
|
||||
|
||||
and you want to migrate assets to minio.
|
||||
|
||||
You could use a convenience script located in `bin/migrate_from_fs_to_minio`.
|
||||
|
||||
Be careful, read carefully what it does, it was not tested in all environments.
|
||||
|
||||
Take it as an inspiration to make your own migration script.
|
||||
78
docs/content/guides/media/s3-google-cloud-storage.md
Normal file
78
docs/content/guides/media/s3-google-cloud-storage.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# Guide - Setup HedgeDoc S3 image upload to Google Cloud Storage
|
||||
|
||||
HedgeDoc has no direct/native support for storing images in Google Cloud Storage Buckets.
|
||||
However since Google provides interoperability with S3, the S3 integration can be used.
|
||||
|
||||
This guide will help you in getting things setup.
|
||||
|
||||
## Setup the bucket
|
||||
|
||||
### Create a bucket in Google Cloud Storage
|
||||
|
||||
1. Create a new bucket [within the Cloud Storage portal](https://console.cloud.google.com/storage/browser).
|
||||
2. Give it a name, select the region and type of storage (e.g. multi dual-region)
|
||||
3. In "Choose how to control access to objects" disable "Enforce public access prevention on this bucket"
|
||||
|
||||
### Open the bucket to the public
|
||||
|
||||
In order to view the images uploaded to HedgeDoc the storage bucket needs to be set to public.
|
||||
|
||||
1. Click the bucket you just created in [the Cloud Storage portal](https://console.cloud.google.com/storage/browser).
|
||||
2. Go to the Permissions tab
|
||||
3. Scroll down to the Permissions section
|
||||
4. Click Grant Access
|
||||
5. Add `allusers` as principal
|
||||
6. Give it role `Storage Object Viewer` to allow it to retrieve the roles
|
||||
|
||||
### Setup interoperability & create Service Account
|
||||
|
||||
1. Go to the [interoperability tab](https://console.cloud.google.com/storage/settings;tab=interoperability) in the Google Cloud Console
|
||||
2. Scroll down to "Access keys for service accounts" and click on "Create a key for a service account"
|
||||
3. Select "Create new account"
|
||||
4. Give it a name, e.g. `hedgedoc`
|
||||
5. Select the `Storage Object Creator` role and select Add IAM Condition
|
||||
6. Give it a name, e.g. `Restrict to bucket`
|
||||
7. In Condition Builder:
|
||||
1. Condition type: Name
|
||||
2. Operator: Starts With
|
||||
3. Value: `projects/_/buckets/YOUR_BUCKET_NAME_HERE`
|
||||
8. Skip the 3rd step (Grant users access to this service account)
|
||||
9. Click done
|
||||
10. Copy the Access Key and Secret to a text editor, we'll be using this later
|
||||
|
||||
### Add permissions
|
||||
|
||||
1. Go to [Roles](https://console.cloud.google.com/iam-admin/roles) within the IAM & Admin section in Google Cloud Console
|
||||
2. Click Create Role
|
||||
3. Give it a name (e.g. `Allow to view buckets`) and an id (e.g. `bucket-viewer`)
|
||||
4. Click Add Permissions
|
||||
5. In the filter (below the dropdown) type `storage.buckets.get`
|
||||
6. Check the box in front of the `storage.buckets.get` entry, click Add.
|
||||
7. Click Create
|
||||
|
||||
8. Go to [IAM & Admin](https://console.cloud.google.com/iam-admin/iam) section and go to the IAM page
|
||||
9. Find the user we created in the previous step and edit it
|
||||
10. Click "Add another role" and select the role we just created
|
||||
11. Select the role we just created and select Add IAM Condition
|
||||
12. Give it a name, e.g. `Restrict to bucket`
|
||||
13. In Condition Builder:
|
||||
1. Condition type: Name
|
||||
2. Operator: Starts With
|
||||
3. Value: `projects/_/buckets/YOUR_BUCKET_NAME_HERE`
|
||||
14. Save it.
|
||||
|
||||
## Configure HedgeDoc
|
||||
|
||||
Set the following environment variables (or the [corresponding config.json values](/configuration/#amazon-s3)):
|
||||
|
||||
```env
|
||||
CMD_IMAGE_UPLOAD_TYPE="s3"
|
||||
CMD_S3_ENDPOINT="https://storage.googleapis.com"
|
||||
CMD_S3_ACCESS_KEY_ID="GOOG1EXXXXXXXXXX"
|
||||
CMD_S3_SECRET_ACCESS_KEY="XXXXXXXXXX"
|
||||
CMD_S3_BUCKET="your-bucket-name"
|
||||
```
|
||||
|
||||
The access key and secret key are the values you received when you enabled the interoperability feature.
|
||||
|
||||
After restarting HedgeDoc you should now be able to add images to your pages.
|
||||
77
docs/content/guides/media/s3-image-upload.md
Normal file
77
docs/content/guides/media/s3-image-upload.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Guide - Setup HedgeDoc S3 image upload
|
||||
|
||||
**Note:** *This guide was written before the renaming. Just replace `HackMD` with `HedgeDoc` in your mind 😃 thanks!*
|
||||
|
||||
1. Go to [AWS S3 console](https://console.aws.amazon.com/s3/home) and create a new bucket.
|
||||

|
||||
|
||||
2. Click on bucket, select **Properties** on the side panel, and find **Permission** section. Click **Edit bucket policy**.
|
||||

|
||||
|
||||
3. Enter the following policy, replace `bucket_name` with your bucket name:
|
||||

|
||||
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": "*",
|
||||
"Action": "s3:GetObject",
|
||||
"Resource": "arn:aws:s3:::bucket_name/uploads/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
4. Go to IAM console and create a new IAM user. Remember your user credentials(`key`/`access token`)
|
||||
|
||||
5. Enter user page, select **Permission** tab, look at **Inline Policies** section, and click **Create User Policy**
|
||||

|
||||
|
||||
6. Select **Custom Policy**
|
||||

|
||||
|
||||
7. Enter the following policy, replace `bucket_name` with your bucket name:
|
||||

|
||||
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:*"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::bucket_name/uploads/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
8. Edit `config.json` and set following keys:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"production": {
|
||||
...
|
||||
"imageuploadtype": "s3",
|
||||
"s3": {
|
||||
"accessKeyId": "YOUR_S3_ACCESS_KEY_ID",
|
||||
"secretAccessKey": "YOUR_S3_ACCESS_KEY",
|
||||
"region": "YOUR_S3_REGION" // example: ap-northeast-1
|
||||
},
|
||||
"s3bucket": "YOUR_S3_BUCKET_NAME"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
9. In additional to edit `config.json` directly, you could also try [environment variables](../../configuration.md).
|
||||
|
||||
## Related Tools
|
||||
|
||||
- [AWS Policy Generator](http://awspolicygen.s3.amazonaws.com/policygen.html)
|
||||
Reference in New Issue
Block a user