-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathFafApiProperties.java
More file actions
311 lines (279 loc) · 8.42 KB
/
Copy pathFafApiProperties.java
File metadata and controls
311 lines (279 loc) · 8.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
package com.faforever.api.config;
import lombok.Data;
import org.checkerframework.checker.index.qual.Positive;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Set;
@Data
@ConfigurationProperties(prefix = "faf-api", ignoreUnknownFields = false)
public class FafApiProperties {
/**
* The API version.
*/
private String version;
private Jwt jwt = new Jwt();
private OAuth2 oAuth2 = new OAuth2();
private Async async = new Async();
private Map map = new Map();
private Mod mod = new Mod();
private Replay replay = new Replay();
private Avatar avatar = new Avatar();
private Clan clan = new Clan();
private Cloudflare cloudflare = new Cloudflare();
private FeaturedMod featuredMod = new FeaturedMod();
private GitHub gitHub = new GitHub();
private Deployment deployment = new Deployment();
private Registration registration = new Registration();
private PasswordReset passwordReset = new PasswordReset();
private Steam steam = new Steam();
private Gog gog = new Gog();
private Mail mail = new Mail();
private Challonge challonge = new Challonge();
private User user = new User();
private Database database = new Database();
private Rating rating = new Rating();
private Tutorial tutorial = new Tutorial();
private Nodebb nodebb = new Nodebb();
private Recaptcha recaptcha = new Recaptcha();
private Monitoring monitoring = new Monitoring();
private Coturn coturn = new Coturn();
private S3 s3 = new S3();
@Data
public static class OAuth2 {
private String resourceId = "faf-api";
}
@Data
public static class Jwt {
/**
* The secret used for JWT token generation.
*/
private Path secretKeyPath;
private Path publicKeyPath;
}
@Data
public static class Async {
private int corePoolSize = Runtime.getRuntime().availableProcessors();
private int maxPoolSize = Runtime.getRuntime().availableProcessors() * 4;
private int queueCapacity = Integer.MAX_VALUE;
}
@Data
public static class Map {
/**
* For instance {@code http://content.faforever.com/faf/vault/map_previews/small/%s}
*/
private String smallPreviewsUrlFormat;
/**
* For instance {@code http://content.faforever.com/faf/vault/map_previews/large/%s}
*/
private String largePreviewsUrlFormat;
/**
* For instance {@code http://content.faforever.com/faf/vault/maps/%s}
*/
private String downloadUrlFormat;
/**
* The directory in which uploaded map files are stored.
*/
private Path targetDirectory = Paths.get("static/maps");
/**
* The directory in which small map previews are stored.
*/
private Path directoryPreviewPathSmall = Paths.get("static/map_previews/small");
/**
* The directory in which large map previews are stored.
*/
private Path directoryPreviewPathLarge = Paths.get("static/map_previews/large");
/**
* The size (in pixels) of small map previews.
*/
@Positive
private int previewSizeSmall = 128;
/**
* The size (in pixels) of large map previews.
*/
@Positive
private int previewSizeLarge = 512;
/**
* Allowed file extensions of uploaded maps.
*/
private Set<String> allowedExtensions = Set.of("zip");
/**
* The default license if no license is provided on upload
*/
@Positive
private int defaultLicenseId;
}
@Data
public static class Mod {
private String previewUrlFormat;
private String downloadUrlFormat;
/** Allowed file extensions of uploaded mods. */
private Set<String> allowedExtensions = Set.of("zip");
/** The directory in which uploaded mod files are stored. */
private Path targetDirectory = Paths.get("static/mods");
/** The directory in which thumbnails of uploaded mod files are stored. */
private Path thumbnailTargetDirectory = Paths.get("static/mod_thumbnails");
/** The maximum allowed length of a mod's name. */
@Positive
private int maxNameLength = 100;
/** The minimum allowed length of a mod's name. */
@Positive
private int minNameLength = 3;
/**
* The default license if no license is provided on upload
*/
@Positive
private int defaultLicenseId;
}
@Data
public static class Replay {
private String downloadUrlFormat;
}
@Data
public static class Avatar {
private String downloadUrlFormat;
private Set<String> allowedExtensions = Set.of("png");
private Path targetDirectory;
private int maxSizeBytes = 4096;
private int maxNameLength = 100;
private int imageWidth = 40;
private int imageHeight = 20;
}
@Data
public static class FeaturedMod {
private String fileUrlFormat;
}
@Data
public static class Clan {
private long inviteLinkExpireDurationMinutes = Duration.ofDays(7).toMinutes();
private String websiteUrlFormat;
}
@Data
public static class Cloudflare {
private String hmacParam;
private String hmacSecret;
}
@Data
public static class GitHub {
private String webhookSecret;
private String accessToken;
private String deploymentEnvironment;
}
@Data
public static class Deployment {
private String featuredModsTargetDirectory;
private String repositoriesDirectory;
private String filesDirectoryFormat = "updates_%s_files";
private String forgedAllianceExePath;
private String testingExeUploadKey;
private String allowedExeExtension = "exe";
private String forgedAllianceBetaExePath;
private String forgedAllianceDevelopExePath;
}
@Data
public static class Mail {
private String fromEmailAddress;
private String fromEmailName;
private Smtp smtp;
}
@Data
public static class Registration {
private long linkExpirationSeconds = Duration.ofDays(7).getSeconds();
private String activationUrlFormat;
private String subject;
private String activationMailTemplatePath;
private String welcomeSubject;
private String welcomeMailTemplatePath;
}
@Data
public static class PasswordReset {
private long linkExpirationSeconds = Duration.ofDays(7).getSeconds();
private String passwordResetUrlFormat;
private String subject;
private String mailTemplatePath;
}
@Data
public static class Steam {
private String realm;
private String apiKey;
private String forgedAllianceAppId = "9420";
private String loginUrlFormat = "https://steamcommunity.com/openid/login";
private String getOwnedGamesUrlFormat = "https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001?key={key}&steamid={steamId}&format={format}&appids_filter[0]={faAppId}";
private String linkToSteamRedirectUrlFormat;
private String steamPasswordResetRedirectUrlFormat;
}
@Data
public static class Gog {
private String tokenFormat;
private String profilePageUrl;
private String gamesListUrl;
}
@Data
public static class Challonge {
private String baseUrl = "https://api.challonge.com";
private String key;
}
@Data
public static class User {
private int minimumDaysBetweenUsernameChange = 30;
private int usernameReservationTimeInMonths = 6;
}
@Data
public static class Database {
/**
* The database schema version required to run this application.
*/
private String schemaVersion;
}
@Data
public static class Smtp {
private String host;
private Integer port;
private String user;
private String password;
}
@Data
public static class Anope {
private String databaseName;
}
@Data
public static class Rating {
private int defaultMean;
private int defaultDeviation;
}
@Data
public static class Tutorial {
private String thumbnailUrlFormat;
}
@Data
public static class Nodebb {
private String baseUrl;
/**
* The nodeBB user id to be impersonated. Id 1 as initial admin should be sufficient.
*/
private int adminUserId;
private String masterToken;
}
@Data
public static class Recaptcha {
private boolean enabled;
private String secret;
}
@Data
public static class Monitoring {
private double slowRequestThresholdSeconds = 1.0;
}
@Data
public static class Coturn {
private int tokenLifetimeSeconds = 86400;
}
@Data
public static class S3 {
private String endpoint;
private String region;
private String userUploadBucket;
private String accessKey;
private String secretKey;
}
}