aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-19 10:43:53 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-10-24 14:48:24 +0200
commit9ab330b90decf4edf152ff8e1d2948c065766b2c (patch)
tree29d924f50f7307e8e828a57ecb9ea78623487ce0 /shared/server-commands/server
parent3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (diff)
downloadPeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.tar.gz
PeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.tar.zst
PeerTube-9ab330b90decf4edf152ff8e1d2948c065766b2c.zip
Use private ACL for private videos in s3
Diffstat (limited to 'shared/server-commands/server')
-rw-r--r--shared/server-commands/server/object-storage-command.ts91
1 files changed, 69 insertions, 22 deletions
diff --git a/shared/server-commands/server/object-storage-command.ts b/shared/server-commands/server/object-storage-command.ts
index b4de8f4cb..405e1b043 100644
--- a/shared/server-commands/server/object-storage-command.ts
+++ b/shared/server-commands/server/object-storage-command.ts
@@ -4,74 +4,121 @@ import { makePostBodyRequest } from '../requests'
4import { AbstractCommand } from '../shared' 4import { AbstractCommand } from '../shared'
5 5
6export class ObjectStorageCommand extends AbstractCommand { 6export class ObjectStorageCommand extends AbstractCommand {
7 static readonly DEFAULT_PLAYLIST_BUCKET = 'streaming-playlists' 7 static readonly DEFAULT_PLAYLIST_MOCK_BUCKET = 'streaming-playlists'
8 static readonly DEFAULT_WEBTORRENT_BUCKET = 'videos' 8 static readonly DEFAULT_WEBTORRENT_MOCK_BUCKET = 'videos'
9 9
10 static getDefaultConfig () { 10 static readonly DEFAULT_SCALEWAY_BUCKET = 'peertube-ci-test'
11
12 // ---------------------------------------------------------------------------
13
14 static getDefaultMockConfig () {
11 return { 15 return {
12 object_storage: { 16 object_storage: {
13 enabled: true, 17 enabled: true,
14 endpoint: 'http://' + this.getEndpointHost(), 18 endpoint: 'http://' + this.getMockEndpointHost(),
15 region: this.getRegion(), 19 region: this.getMockRegion(),
16 20
17 credentials: this.getCredentialsConfig(), 21 credentials: this.getMockCredentialsConfig(),
18 22
19 streaming_playlists: { 23 streaming_playlists: {
20 bucket_name: this.DEFAULT_PLAYLIST_BUCKET 24 bucket_name: this.DEFAULT_PLAYLIST_MOCK_BUCKET
21 }, 25 },
22 26
23 videos: { 27 videos: {
24 bucket_name: this.DEFAULT_WEBTORRENT_BUCKET 28 bucket_name: this.DEFAULT_WEBTORRENT_MOCK_BUCKET
25 } 29 }
26 } 30 }
27 } 31 }
28 } 32 }
29 33
30 static getCredentialsConfig () { 34 static getMockCredentialsConfig () {
31 return { 35 return {
32 access_key_id: 'AKIAIOSFODNN7EXAMPLE', 36 access_key_id: 'AKIAIOSFODNN7EXAMPLE',
33 secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' 37 secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
34 } 38 }
35 } 39 }
36 40
37 static getEndpointHost () { 41 static getMockEndpointHost () {
38 return 'localhost:9444' 42 return 'localhost:9444'
39 } 43 }
40 44
41 static getRegion () { 45 static getMockRegion () {
42 return 'us-east-1' 46 return 'us-east-1'
43 } 47 }
44 48
45 static getWebTorrentBaseUrl () { 49 static getMockWebTorrentBaseUrl () {
46 return `http://${this.DEFAULT_WEBTORRENT_BUCKET}.${this.getEndpointHost()}/` 50 return `http://${this.DEFAULT_WEBTORRENT_MOCK_BUCKET}.${this.getMockEndpointHost()}/`
47 } 51 }
48 52
49 static getPlaylistBaseUrl () { 53 static getMockPlaylistBaseUrl () {
50 return `http://${this.DEFAULT_PLAYLIST_BUCKET}.${this.getEndpointHost()}/` 54 return `http://${this.DEFAULT_PLAYLIST_MOCK_BUCKET}.${this.getMockEndpointHost()}/`
51 } 55 }
52 56
53 static async prepareDefaultBuckets () { 57 static async prepareDefaultMockBuckets () {
54 await this.createBucket(this.DEFAULT_PLAYLIST_BUCKET) 58 await this.createMockBucket(this.DEFAULT_PLAYLIST_MOCK_BUCKET)
55 await this.createBucket(this.DEFAULT_WEBTORRENT_BUCKET) 59 await this.createMockBucket(this.DEFAULT_WEBTORRENT_MOCK_BUCKET)
56 } 60 }
57 61
58 static async createBucket (name: string) { 62 static async createMockBucket (name: string) {
59 await makePostBodyRequest({ 63 await makePostBodyRequest({
60 url: this.getEndpointHost(), 64 url: this.getMockEndpointHost(),
61 path: '/ui/' + name + '?delete', 65 path: '/ui/' + name + '?delete',
62 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 66 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
63 }) 67 })
64 68
65 await makePostBodyRequest({ 69 await makePostBodyRequest({
66 url: this.getEndpointHost(), 70 url: this.getMockEndpointHost(),
67 path: '/ui/' + name + '?create', 71 path: '/ui/' + name + '?create',
68 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 72 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
69 }) 73 })
70 74
71 await makePostBodyRequest({ 75 await makePostBodyRequest({
72 url: this.getEndpointHost(), 76 url: this.getMockEndpointHost(),
73 path: '/ui/' + name + '?make-public', 77 path: '/ui/' + name + '?make-public',
74 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 78 expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307
75 }) 79 })
76 } 80 }
81
82 // ---------------------------------------------------------------------------
83
84 static getDefaultScalewayConfig (serverNumber: number) {
85 return {
86 object_storage: {
87 enabled: true,
88 endpoint: this.getScalewayEndpointHost(),
89 region: this.getScalewayRegion(),
90
91 credentials: this.getScalewayCredentialsConfig(),
92
93 streaming_playlists: {
94 bucket_name: this.DEFAULT_SCALEWAY_BUCKET,
95 prefix: `test:server-${serverNumber}-streaming-playlists:`
96 },
97
98 videos: {
99 bucket_name: this.DEFAULT_SCALEWAY_BUCKET,
100 prefix: `test:server-${serverNumber}-videos:`
101 }
102 }
103 }
104 }
105
106 static getScalewayCredentialsConfig () {
107 return {
108 access_key_id: process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID,
109 secret_access_key: process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY
110 }
111 }
112
113 static getScalewayEndpointHost () {
114 return 's3.fr-par.scw.cloud'
115 }
116
117 static getScalewayRegion () {
118 return 'fr-par'
119 }
120
121 static getScalewayBaseUrl () {
122 return `https://${this.DEFAULT_SCALEWAY_BUCKET}.${this.getScalewayEndpointHost()}/`
123 }
77} 124}